set dictionary python code example
Example 1: how to set a key of dict in python
# declaring dict
dictionary={'Hello':3,'World!':4}
# creating function
def dict_add(obj,key,value):
obj[key]=value
reutrn obj
# using the functiom
dict_add(dictionary,'Python',10)
print (dictionary) # output --> { 'Hello':3 ,'World!':4 , 'Python':10 }
Example 2: python dictionary
#title :Dictionary Example
#author :Josh Cogburn
#date :20191127
#github :https://github.com/josh-cogburn
#====================================================
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
#Assigning a value
thisdict["year"] = 2018