keys() returns a list of the dictionary's keys, : Keys : Dictionary PYTHON TUTORIALS


PYTHON TUTORIALS » Dictionary » Keys »

 

keys() returns a list of the dictionary's keys,


values() returns a list of the dictionary's values
items() returns a list of (key, valuetuple 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]



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Dictionary
» Keys