I have a simple question (or so I thought).
I have a dictionary, lets say it looks like this:
dict = {'A':100, 'a':10, 'T':50, 't':5}
I simply want to delete the key with the highest value. I tried this:
del max(dict.values())
and this is the error message: ‘Syntax Error: can´t delete function call’.
I want the end result to be:
dict = {'a':10, 'T':50, 't':5}
max(d.values())will give you the maximum value (100), but to delete an entry from a dictionary you need the corresponding key ('A').You can do this:
By the way, you shouldn’t name your dictionary
dictbecause that’s the name of a built-in type.If there may be multiple entries with the same maximum value and you want to delete all of them: