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
  • 17,016
  • 6
  • 45
  • 76
toto'
  • 1,146
  • 1
  • 11
  • 28

0 Answers0