1d = {'key':'value'}
2print(d)
3# {'key': 'value'}
4d['mynewkey'] = 'mynewvalue'
5print(d)
6# {'mynewkey': 'mynewvalue', 'key': 'value'}
7
1dict_1 = {"1":"a", "2":"b", "3":"c"}
2dict_2 = {"4":"d", "5":"e", "6":"f"}
3
4dict_1.update(dict_2)
5print(dict_1)
6#Output = {"1":"a", "2":"b", "3":"c", "4":"d", "5":"e", "6":"f"}
1mydict = {'score1': 41,'score2': 23}
2mydict['score3'] = 45 # using dict[key] = value
3print(mydict)
1default_data = {'item1': 1,
2 'item2': 2,
3 }
4
5default_data.update({'item3': 3})
6# or
7default_data['item3'] = 3
1testing1={'one':1,'two':2}
2''' update() is the method of dict() merges another dict into existing ones '''
3''' it replaces the keys of exisiting ones with the the new ones '''
4testing1.update({'two':3,'noice':69})
5print(testing1) """ {'one':1,'two':3,'noice':69} """
1>>> d1 = {1: 1, 2: 2}
2>>> d2 = {2: 'ha!', 3: 3}
3>>> d1.update(d2)
4>>> d1
5{1: 1, 2: 'ha!', 3: 3}