dictionnary python key code example
Example 1: dictionary in python
d = {'key1':'value1','key2':'value2'}
print(d) # to print full dictionary
l=d.keys
print(l) # to print keys
b=d.values
print(b)#to print values in dictionary
Example 2: dictionary in python
#A dictionary has key-value pairs. Here 1,2,3 are the keys and Item1,Item2,Item3
#are their values respectively.
dictionaryName = { 1: "Item1", 2: "Item2", 3: "Item3"}
#retrieving value of a particular key
dictionaryName[1]
#retrieving all the keys in a dictionary
dictionaryName.keys()
#retrieving all the values in a dictionary
dictionaryName.values()