
def get_max_value_and_key(a_dict):

def get_max_value_and_key(a_dict):
value=None
key=''
for k,v in a_dict.items():
if value==None or value<v:
value=v
key=k
return key,value
data_dict={'cat':91,'hello':24,'a':413,'word':-1,'dog':135}
print(get_max_value_and_key(data_dict))
d = {"cat":91, "hello": 24, "a":413, "world":-1}
def get_max_value(data_dict):
max_value = max(data_dict.values())
for i, v in data_dict.items():
if v == max_value:
return (i, v)
print(get_max_value(d))

def get_max_value_and_key(a_dict):
return max(a_dict.items(),key=lambda x:x[1])
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>>
https://vip.csdn.net/askvip?utm_source=1146287632