I'm trying to create a dictionary where keys are strings and values are lists. Something like that
l1 = ['a', 'b', 'c']
and I want to add lists similar to that one in every iteration in a for loop.
I've tried this
dicc['first'].append(l1)
The exit should be something like that:
dicc={'first': ['a', 'b', 'c']}
I always get the same error: list indices must be integers or slices, not str
How can i do it?
diccas a dictionary with something likedicc = {}?from collections import defaultdictdicc = defaultdict(list)l1 = ['a', 'b', 'c']for x in l1:dicc["first"].append(x)like this?