213k views
1 vote
PYTHON:Given the dictionary, d, find the largest key in the dictionary and associate the corresponding value with the variable val_of_max. For example, given the dictionary {5:3, 4:1, 12:2}, 2 would be associated with val_of_max. Assume d is not empty.

User Emeke Ajeh
by
4.8k points

1 Answer

4 votes

di = {5: 3, 4: 1, 12: 2}

val_of_max = di[max(di)]

print(val_of_max)

I hope this helps!

User Morten Fjeldstad
by
5.7k points