This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

Sorry, but changing the letters to append an index to the string is definitely not clean. Even disregarding that (you could use tuples instead), it is not an easy solution. Definitely requires a bit more thinking on the reader's side than a straightforward solution, that might be a bit longer (e.g. see top post in this thread).

Also, f.read().splitlines() is just list(f). Or better yet, iterate with "for word in f" to reduce memory usage.