Print the keys

EasyDictionary Programs · 70 of 94

Write a Python program to print the keys of a dictionary, capitalised.

Advertisement
Input
{"pepsi": 50, "sprite": 60, "slice": 55}
Output
Pepsi
Sprite
Slice

Approach

  1. Loop over the dict.

Solution

Python
drinks = {"pepsi": 50, "sprite": 60, "slice": 55}for name in drinks:    print(name.title())
Output
Pepsi
Sprite
Slice
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More dictionary programs

← All 94 Dictionary Programs