0

Dictionaries in Python

How can I append an object to a dictionary!??

18th Mar 2019, 8:37 PM
Mohammed ElSaid SARHANI
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'})
18th Mar 2019, 10:21 PM
Ameer Abdulaziz
Ameer Abdulaziz - avatar
+ 3
Different to lists, you just assign, there will be no error. d['key'] = 'value'
18th Mar 2019, 8:46 PM
HonFu
HonFu - avatar