문제

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?

도움이 되었습니까?

해결책

You forgot the key keyword.

h = max(d, key=lambda p: p[1])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top