Creating a dictionary and traversing

d={10: 'iprg' , 22: 'Nan', 33:'Kool',8: 'Jool' } # Creating a dictionary with key: value pair

for i in d:                                     # Here key and the vaule can be any type.
  print i,d[i]                                  # Accessing elements in the dictionary

# Order in which they display is also different in output

print d.keys()  # print all keys in a dictionary

print d.values()  # print all values in a dictionary


No comments: