我试图在测试之后将一些键添加到我的字典中,如果它们已经是现有键.但是每次我得到它,我似乎都无法进行测试TypeError "argument of type 'type' not iterable.
这基本上是我的代码:
dictionary = dict
sentence = "What the heck"
for word in sentence:
if not word in dictionary:
dictionary.update({word:1})
Run Code Online (Sandbox Code Playgroud)
我也试过,if not dictionary.has_key(word)但它也没用,所以我真的很困惑.