Say I have the following in a text file:
car apple bike book
How can I read it and put them into a dictionary
words = [] for word in open('words.txt'): words.append(word.rstrip('\n'))
The words list will contain the words in your file. strip removes the newline characters.
words
strip