I am initializing a sequence like this
seq = {'a', 'b', 'c', 'd', 'e'}
Now I am using fromkeys() to convert sequence to dict of sets. here is what I am doing:
val = set()
seq_dict = dict.fromkeys(seq, val)
Now it seems if add an element to only one of my dictionary keys set, that element is being added to all the other sets. Here is the example:
seq_dict['a'].add("val1")
print(seq_dict)
{'d': {'val1'}, 'c': {'val1'}, 'b': {'val1'}, 'a': {'val1'}, 'e': {'val1'}}
Not sure if I am using the fromkeys in a right way though?