0
How can I add a value in a list for a key in a dictionary??
For example dicc={colors:[blue]} --> dicc={colors: [blue, red]}
3 odpowiedzi
0
Looking for something like this?
>>> x = {1:2}
>>> print x
{1: 2}
>>> x.update({3:4})
>>> print x
{1: 2, 3: 4}
See https://www.tutorialspoint.com/JUMP_LINK__&&__python__&&__JUMP_LINK/dictionary_update.htm
0
Thanks
- 2
dict_name[key].append(value)
Something wrong? It is right answer