Mega Code Archive

 
Categories / Python Tutorial / Dictionary
 

Indexing a Dictionary

d = { 'x':42, 'y':3.14, 'z':7 } print d['x']                           # 42 print d['z']                           # 7 print d['a']                           # raises KeyError exception