set key value dictionary python code example
Example 1: how to set a key of dict in python
dictionary={'Hello':3,'World!':4}
def dict_add(obj,key,value):
obj[key]=value
reutrn obj
dict_add(dictionary,'Python',10)
print (dictionary)
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: append dictionary python
>>> d1 = {1: 1, 2: 2}
>>> d2 = {2: 'ha!', 3: 3}
>>> d1.update(d2)
>>> d1
{1: 1, 2: 'ha!', 3: 3}