Category : dictionary

How can I write orders with loop, dictionary and if statement by python If I want the output result from dictionary list and for the others input print a sentence Here is my program could someone find what is the solution for the mistakes def phone_guide(): guide_number = input("Enter a number:") numbers = {"Amal": 1111111111, ..

Read more

I have a csv file (uneditable), which looks like this: fruit,price,amount apple,1,2 banana,3,4 kiwi,5,6 that I’ve read into a list of dicts: goodies = [] with open(blabla) as file: reader = csv.DictReader(file) for fruit in file: goodies.append(fruit) It looks like this: goodies = [{‘fruit’ : ‘apple’, ‘price’ : ‘1’, ‘amount’:’2′}, {‘fruit’ : ‘banana’, ‘price’ : ..

Read more

My code as it is right now looks like this: def read_in_movie_preference(): """Read the move data, and return a preference dictionary.""" preference = {} movies = [] # write code here: file_location="./data/" f = open(file_location+"preference.csv","r") df = f.readlines() #names as keys and prefrences for line in df: name = line[1].strip("n").split(",") prefs = line[2:].strip("n").split(",") preference[line[1]] = ..

Read more