w3resource logo


Python Exercises

Python Exercise: Program to iterate over dictionaries using for loops


Write a Python program to iterate over dictionaries using for loops.

Sample Solution :

Python Code :

d = {'x': 10, 'y': 20, 'z': 30} 
for dict_key, dict_value in d.items():
    print(dict_key,'->',dict_value)

Console :

Copy and paste the above code and press "Enter key" to execute :

Post your code through Disqus