Iterate over dictionaries in Python

Python

Iterate over dictionaries in Python

#create a dict
mydict = {'jason':5,
'terry':1,
'michael':3,
'sam':6}

#using for loops
for key, value in mydict.items():
print (key, 'corresponds to', value)
terry corresponds to 1
jason corresponds to 5
michael corresponds to 3
sam corresponds to 6