Python Practice › Loop Programs › Program 66
Print the keys of a dictionary
Write a Python program to print the keys of a dictionary using a loop.
Input
{"name": "virat", "sports": "cricket"}Output
name sports
Approach
- Looping over a dict gives its keys.
Solution
player = {"name": "virat", "sports": "cricket"}for key in player: print(key)Output
name sports
Learn the concept
New to this topic? Read the lesson, then come back.