dimanche 18 décembre 2016

Why do i get the TypeError "argument of type 'type' is not iterable"?

I am trying to add some keys to my dictionary after testing if they are already existing keys. But I seem not to be able to do the test, every time I get the TypeError "argument of type 'type' not iterable.

This is basically my code:

dictionary = dict
sentence = "What the heck"
for word in sentence:
      if not word in dictionary:
             dictionary.update({word:1})

I also tried if not dictionary.has_key(word) but it didn't work either so I am really confused.

Aucun commentaire:

Enregistrer un commentaire