Top Value Key

A dictionary can store player scores, product prices, or statistics by category. The function key_of_max receives a non-empty dictionary d and returns the key with the largest value. If several keys share the same maximum value, return the key that appears first during dictionary iteration.

Примеры

Ввод
{"a": 1, "b": 3, "c": 2}
Вывод
"b"
Ввод
{"x": 5}
Вывод
"x"
Ввод
{"a": 2, "b": 2}
Вывод
"a"

Нужно реализовать

def key_of_max(d: dict):

Теги

dicthashmap
PostgreSQLv16

Hawn jidher ir-riżultat tat-tħaddim tal-kodiċi

Visible tests
1
Input
{"a":1,"b":3,"c":2}
Expected"b"
2
Input
{"x":5}
Expected"x"
3
Input
{"a":2,"b":2}
Expected"a"
4
Input
{"hi":-1,"lo":-5}
Expected"hi"
5
Input
{"p":10,"q":20,"r":15}
Expected"q"
6
Input
{}
ExpectedNone
Focus radio
Paused · SomaFM · Fluid