I have a one line text file, file.txt
which contents are:
["word 1","word 2","word 3","word 4"]
I want to open this file so that Python reads it as a list.
When I use:
line = (literal_eval(s) for s in open("file.txt"))
print(len(line))
I notice that line
variable is a list with just one item, as that prints out 1
How do I open file.,txt
to get a list with 4 items ("word 1", "word 2", "word 3", "word 4")?
Thanks.