Answers for "how to set a key of dict in python"

2

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 }
Posted by: Guest on September-22-2020

Code answers related to "how to set a key of dict in python"

Python Answers by Framework

Browse Popular Code Answers by Language