所以我是python的初学者,我正在做一个任务,需要我计算列表中的项目数,计算每个项目并将其放入字典中。 最后我确实设法使程序工作,但我不明白为什么这段代码不起作用
def stringinlist(*strings):
dictionary = {}
count = 0
for objects in strings:
if objects in dictionary == False:
for check in strings:
if objects == check:
count += 1
dictionary[objects] = count
count = 0
return dictionary
print(stringinlist("yo","hello","hello","yo"))
我尝试调试并看到“如果字典中的对象..”即使它应该返回False也不起作用 任何解释?