python字典如果不识别False

时间:2018-02-18 23:01:01

标签: python dictionary

所以我是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也不起作用 任何解释?

0 个答案:

没有答案
相关问题