小编sor*_*ted的帖子

找到具有最大值的键并打印其值(字典,python)

假设我们有一个字典,

   dict = {'blue': ['sky','sea'], 'orange': ['carrots','sunset','oranges'], 'green': ['grass']}
Run Code Online (Sandbox Code Playgroud)

输出应该是

['carrots','sunset','oranges']
Run Code Online (Sandbox Code Playgroud)

因为它获得了最多的值.

这是我到目前为止:

for k,v in dict.items():
    print(max(k,len(v)))
Run Code Online (Sandbox Code Playgroud)

python sorting dictionary

1
推荐指数
1
解决办法
112
查看次数

标签 统计

dictionary ×1

python ×1

sorting ×1