0
Dictionaries in Python
How can I append an object to a dictionary!??
2 ответов
+ 6
To append one item to data dictionary:
data['key'] = 'value'
To append two items to data dictionary:
data['key1'] = 'value1'
data['key2'] = 'value2'
Or just one line by write
data.update({'key1': 'value1', 'key2': 'value2'})
+ 3
Different to lists, you just assign, there will be no error.
d['key'] = 'value'