0

I struggle to understand the following code, how can add() apply to the set in the following dictionary:

for word in tokenize(name):
    index.setdefault(word, set()).add(char)

"add()" is method of set and not a method of dictionary. So how can it be that is adding values to the set in a dictionary?

how can the method .add(char) be

Sraw
  • 18,892
  • 11
  • 54
  • 87
toto'
  • 1,325
  • 1
  • 17
  • 36

0 Answers0