Python Practice › Loop Programs › Program 66

Print the keys of a dictionary

EasyLoop Programs · 66 of 90

Write a Python program to print the keys of a dictionary using a loop.

Advertisement
Input
{"name": "virat", "sports": "cricket"}
Output
name
sports

Approach

  1. Looping over a dict gives its keys.

Solution

Python
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.

More loop programs

← All 90 Loop Programs

Leave a Comment