How to append item to a list in a dictionary in Python

1 Answer

0 votes
dictionary = {'a': 1, 'b': 2, 'c': 3, 'd': [56, 12, 65, 99]}

item = {'e': 5}

dictionary['d'].append(item['e'])

print(dictionary['d'])


'''
run:

[56, 12, 65, 99, 5]

'''

 



answered Oct 31, 2017 by avibootz

Related questions

...