From a text file lines_of_words.txt
, say
first
second
third
a list of words as strings has to be created, i.e.
list_of_strings = ['first', 'second', 'third']
This seems like an extremely trivial function, but I can't find a concise solution. My attempts are either too cumbersome or produce a wrong output, e.g.
['f', 'i', 'r', 's', 't', '\n', 's', 'e', 'c', 'o', 'n', 'd', '\n', 't', 'h', 'i', 'r', 'd', '\n']
or
first
second
third
What is the most pythonic function to get this done? My starting point so far has been
with open('list_of_words', 'r') as list_of_words:
# Do something...
print(list_of_strings)