So far I can create a list with the games (code below), how can I convert it to a dictionary in the style {'CODBO':('Call of Duty BlackOps',120), ...}?
Code:
def load_games(filename) :
games = {}
f = open(filename, 'U')
s = ''
for line in f:
s += line
sList = s.split(',')
return sList
x = load_games('games.txt')
print x
Yeh I know most of the basics with dictionaries and files, that code helps a lot, Ill try to include it in a for loop and iterate over every line. Ill post the code soon if it doesn't work. Thanks
Hello, I have a text file with information on products, the first 3 lines can be seen below
CODBO, Call of Duty BlackOps, 120
SC2WL, Starcraft 2 WoL, 90
FONV0, Fallout New Vegas 100
CODBO is the ID, Call... is the name and 120 is the price.
What would the code be for a function that would turn that into a dictionary that looks similarly to this:
{'CODBO':('Call of...
Leave a comment: