I have a list of lists, called my_list
:
['sit', (1, 1)]
['laboris', (2, 1)]
['nisi', (2, 1)]
['est', (4, 1)]
['qui', (4, 1)]
['cillum', (3, 1)]
['voluptate', (3, 1)]
['eu', (3, 1)]
['irure', (3, 1)]
['sunt', (4, 1)]
['reprehenderit', (3, 1)]
['nulla', (3, 1)]
['sint', (4, 1)]
['fugiat', (3, 1)]
['dolore', (2, 1)]
['dolore', (3, 1)]
['enim', (2, 1)]
['occaecat', (4, 1)]
['tempor', (2, 1)]
['commodo', (2, 1)]
['non', (4, 1)]
['minim', (2, 1)]
['aute', (3, 1)]
['ut', (2, 2)]
['ex', (2, 1)]
['deserunt', (4, 1)]
['ea', (2, 1)]
['eiusmod', (2, 1)]
['culpa', (4, 1)]
['labore', (2, 1)]
['mollit', (4, 1)]
['officia', (4, 1)]
['cupidatat', (4, 1)]
['adipiscing', (2, 1)]
['amet', (1, 1)]
['et', (2, 1)]
['ad', (2, 1)]
['consectetur', (2, 1)]
['anim', (4, 1)]
['magna', (2, 1)]
['quis', (2, 1)]
['ullamco', (2, 1)]
['dolor', (1, 1)]
['dolor', (3, 1)]
['aliquip', (2, 1)]
['velit', (3, 1)]
['ipsum', (1, 1)]
['incididunt', (2, 1)]
['sed', (2, 1)]
['id', (4, 1)]
['esse', (3, 1)]
['exercitation', (2, 1)]
['nostrud', (2, 1)]
I have tried:
d = {}
for item in all_lists:
d[item[0]] = item[1:]
print (d)
But this overwrites a key, instead of updating that value. For example, dolor
becomes: {'dolor': [(3,1)]
instead of the desired goal of: {'dolor': (3,1), (1,1), etc...}
Ideally, the dictionary shape would not include a list of tuples as the value, but if need be.
How can I convert that list of lists to a dict in the format I would like?
I have observed Python: List of lists to dictionary but that yielded me the incorrect I have right now.