Sorry but that code with comment is 21 lines and messy
It's just reading a file into a list,the 3 lines from @Grib do the same in a much nicer way.
Just to make it clear,commenting when not needed can make code less readable.
If need comments,try to use doc string.
![Dodgy Dodgy](https://python-forum.io/images/smilies/dodgy.png)
It's just reading a file into a list,the 3 lines from @Grib do the same in a much nicer way.
Just to make it clear,commenting when not needed can make code less readable.
range(0,len(words_raw)):
is not good Never use "for i in range(len(sequence))If need comments,try to use doc string.
def read(self, file_path): '''Read a file to a list and split on new lines(removed)''' with open(file_path) as stream_reader: return [line.strip() for line in stream_reader if line.strip()]