Python program to Check if a Given key exists in a Dictionary

CountryCodeDict = {"India": 91, "UK" : 44 , "USA" : 1}
print(CountryCodeDict)
CountryCodeDict["Spain"]= 34
print "After adding"
print(CountryCodeDict)

OUTPUT:

{'India': 91, 'USA': 1, 'UK': 44}
After adding
{'Spain': 34, 'India': 91, 'USA': 1, 'UK': 44}

Leave a Comment