【发布时间】:2020-05-02 17:16:36
【问题描述】:
收到错误太多值无法解压。谁能帮我解决一下?
friendship = {'nino': ["tamari", "nika", "lela", "dato"],
'dato': ["tamari", "nino"],
'tamari': ["nino", "dato", "lela"],
'nika': ["nino"],
'lela': ["nino", "tamari"]
}
def f(**friendship):
sia={}
for i in friendship.values():
m = min(i)
for k,v in friendship.items():
sia.update({k:(len(v))})
low = min(sia.values())
res = [x for x,y in sia if sia.items() if y == low]
print(str(res) + " has " + str(low) + " friends") ------ getting an error on this line.
print (f(**friendship))
【问题讨论】:
-
打印 (f(friendship))
-
错误实际上是在
res = [x for x,y in sia if sia.items() if y == low]。如果您尝试@High-Octane 的建议,错误将变为TypeError: f() takes 0 positional arguments but 1 was given -
该方法的目标是什么?你期待什么结果?
标签: python dictionary key-value valueerror