I am trying to create a program that will read a text file and create a list of lines of words.
However am only able to append each line and not word, any help would be appreciated with this problem.
text = open("file.txt","r")
for line in text.readlines():
sentence = line.strip()
list.append(sentence)
print list
text.close()
Example text
I am here
to do something
and I wanted it to append it like this
[['I','am','here']['to','do','something']]
Thanks in advance.
listas variable name. I think you meantext.close()instead offile.close()