I have a list:
Marks =[
[12345,75,'English'],
[23452,83,'Physics'],
[23560,81,'Statistics'],
[23415,61,'Computer'],
[23459,90,'Physics'],
[12345,75,'Computer'],
[23452,100,'Statistics']
]
and I want to make a dictionary where the class name is the key and the two numbers are the values. I can make the initial dictionary like this:
for i in list1:
dict1[i[2]]=i[0],i[1]
But when I print the dictionary, only one of each of the pairs of numbers associated is printed. I'm looking for a result like:
{
'English' : [[12345,75]],
'Physics' : [[23452,83], [23459,90]],
'Statistics' : [[23560,81], [23452,100]],
'Computer' : [[23415,61], [12345,75]]
}
Is there any way I can extend the values associated with a key?
I tried:
if i[2] in dict1:
dict1.extend
print( {i[-1]: i[:2] for i in Marks} )?