append items to a dictionary python code example
Example 1: add item to python dictionary
data = dict()
data['key'] = value
Example 2: python3 add dictionary to dictionary
dict_1 = {"1":"a", "2":"b", "3":"c"}
dict_2 = {"4":"d", "5":"e", "6":"f"}
dict_1.update(dict_2)
print(dict_1)
Example 3: add value to dictionary python
dict[key] = value
Example 4: dictionary append value python
d = {1:2}
d.update({2: 4})
print(d)
Example 5: append dictionary python
>>> d1 = {1: 1, 2: 2}
>>> d2 = {2: 'ha!', 3: 3}
>>> d1.update(d2)
>>> d1
{1: 1, 2: 'ha!', 3: 3}
Example 6: Python dict add item
dictionary_name[key] = value