Python Practice › Dictionary Programs › Program 70
Print the keys
Write a Python program to print the keys of a dictionary, capitalised.
Input
{"pepsi": 50, "sprite": 60, "slice": 55}Output
Pepsi Sprite Slice
Approach
- Loop over the dict.
Solution
drinks = {"pepsi": 50, "sprite": 60, "slice": 55}for name in drinks: print(name.title())Output
Pepsi Sprite Slice
Learn the concept
New to this topic? Read the lesson, then come back.