def invertdict(d):
    id = dict()
for key, value in list(d.items()):
    for part in value:
        if part in id:
            id[part] = id[part] + (key,)
else:
    id[part] = key,
return id
Finding equality between different strings that should be equal