Python Practice › Dictionary Programs › Program 19
Iterate over a dictionary
Write a Python program to loop over a dictionary and print each key and value.
Input
{"food": "burger", "type": "fast food"}Output
food : burger type : fast food
Approach
for k, v in d.items().
Solution
d = {"food": "burger", "type": "fast food"}for key, value in d.items(): print(key, ":", value)Output
food : burger type : fast food
Learn the concept
New to this topic? Read the lesson, then come back.