I have a list of tuples. For example:
L = [(334, 269, 461, 482), (182, 178, 307, 471),(336, 268, 466, 483), (183, 177, 304, 470)]
The length of the list sometimes changes, it is not constant but the key is the same (for example, u'person')
key = u'person'
I tried to create the dictionary from the key and list, Unfortunately, it took the first tuple only. the output was:
{u'person': (334, 269, 461, 482)}
Here, the value was as tuple but I would like the output will be:
{u'person': [(334, 269, 461, 482), (182, 178, 307, 471),(336, 268, 466, 483), (183, 177, 304, 470)]}
Here, the value is list of tuples.
CodePudding user response:
You can use:
new_dict = {u'person': L}
Output:
{u'person': [(334, 269, 461, 482), (182, 178, 307, 471),(336, 268, 466, 483), (183, 177, 304, 470)]}