You forgot the key
keyword.
h = max(d, key=lambda p: p[1])
Frage
I have a dictionary d
like so:
d = {
(1, 3): False,
(4, 0): False,
(0, 7): True
}
Now I want to get the highest y
coordinate from the dictionary's keys:
h = max(d, lambda p: p[1])
But this raises an error:
TypeError: unorderable types: function() > dict()
What am I doing wrong?
Lösung
You forgot the key
keyword.
h = max(d, key=lambda p: p[1])