Mega Code Archive

 
Categories / Python Tutorial / Dictionary
 

To loop over the keys of a dictionary, you can use a plain for statement

d = {'x': 1, 'y': 2, 'z': 3}  for key in d:      print key, 'corresponds to', d[key]