Mar-01-2020, 09:52 AM
First question: what is a dictionary? A dictionary is a structure with name - value pairs. In your assignment it appears the keys are fixed. The keys must be: "Name, "sub1", "sub2" and "sub3".
So start easy. You already have a function to make a list of values. You only have to link these values to the keys. Like this:
So start easy. You already have a function to make a list of values. You only have to link these values to the keys. Like this:
ll = ["Arun", 75, 65, 82] dd = {} dd["Name"] = ll[0] dd["sub1"] = ll[1] dd["sub2"] = ll[2] dd["sub3"] = ll[3] print(dd)
Output:{'Name': 'Arun', 'sub1': 75, 'sub2': 65, 'sub3': 82}
Now try to incorporate this in your program. When that works also look at the hint of Perfringo. His solution is more beautiful. But first try to make it work as simple as possible.