How to read a file without newlines?

You can read the whole file and split lines using str.splitlines: Or you can strip the newline by hand: Note: this last solution only works if the file ends with a newline, otherwise the last line will lose a character. This assumption is true in most cases (especially for files created by text editors, which often do add an … Read more