I'm creating a program that has the user's name and their answers to a guess the number game in a database - like format on Python. I have created a text file where all of the users' data is, in the form name : guess. For instance,
Dave:23
Adam:12
Jack:13
Dave:25
Adam:34
Now, I am trying to re - read the file into Python as a tuple, so I decided to use the line of code below (The real answer is 17):
dict(line.split(':', 1) for line in open('guesses.txt'))
But this will just hand me back an empty line in the IDLE.
Why is this not working?
To make it more simple, I need a tuple that has the user's name and then their guesses.
My dictionary should look like this:
{'Dave': 23 25, 'Jack' : 13, 'Adam' : 13 34}
Thanks, Delbert.