I have a problem adding a value to a set which is a value in a dictionary. I have to use sets as values not list or anything else. I have seen this thread but it does not full ansver me.
from collections import defaultdict
datoteka = open("vzorec.list","rt")
slovar = defaultdict(set)
for vrstica in datoteka:
    seznam = vrstica.split("\t")
    naslov = seznam[0]
    beseda = seznam[len(seznam)-1]
    beseda = beseda.strip()
    naslov2 = ""
    for crka in naslov:
        if crka == "(":
            break
        else:
            naslov2 = naslov2 + crka
    naslov = naslov2.lstrip('"')
    if naslov not in slovar:
        slovar[naslov] = set(beseda)
    elif naslov in slovar:
        slovar[naslov] = slovar[naslov].add(beseda)
print(slovar)
I get an error that a string type does not have an add function. But why does python not understand that I want to have sets as values. I even used the defaultdict
 
     
     
    