dictionary add item in specific position python code example
Example 1: Python dictionary append
testing1={'one':1,'two':2}
''' update() is the method of dict() merges another dict into existing ones '''
''' it replaces the keys of exisiting ones with the the new ones '''
testing1.update({'two':3,'noice':69})
print(testing1) """ {'one':1,'two':3,'noice':69} """
Example 2: dictionary append value python
d = {1:2}
d.update({2: 4})
print(d) # {1: 2, 2: 4}