I'm trying to write a function to add the results of a loop to a set, basically taking a list and using set() to take out any duplicate letters in the strings within the list.
However; whenever I run the code, I hit an error that says .add isn't a dict definition.
def make_itemsets(L):
item_set = {}
for item in L:
item_set.add(set(item))
return item_set
2 item_set = {}
3 for item in L:
----> 4 item_set.add(set(item))
5 return item_set
6
AttributeError: 'dict' object has no attribute 'add'
Any ideas? I'm basically trying to get this list (L = ["apples","bananas","carrot"] to run through a function I've created to return a new list [{'a','p','l','e','s'},{'b','a','n','s'} etc. etc.]