Mega Code Archive

 
Categories / Python Tutorial / Dictionary
 

Keys() returns a list of the dictionarys keys

values() returns a list of the dictionary's values items() returns a list of (key, value) tuple pairs.  dict1 = {'A':'1', 'B':'2' } print dict1.keys() print dict1.values() print dict1.items() for eachKey in dict1.keys():    print 'dict1 key', eachKey, 'has value', dict1[eachKey]