Can someone explain how to add a file to a dictionary.
The file is simple. Maybe a word or a number on each line.
Here is the code I have. Didn't know if i should use this post or the List and Dictionaries post so kind of posted twice... sorry
import random
def main():
##Open a file
outfile = open('numbers.txt', 'w')
for count in range(20):
##Get random numbers
rebmun = random.randint(1,99)
outfile.write(str(rebmun) + '\n')
outfile.close()
text = open('numbers.txt','r').read()
muns = text.split()
numbers = {}
for ch in muns:
numbers[ch] = numbers.values()
print numbers
main()