livepython.net

117. Python Program to Print a Menu from a Dictionary

EasyLooping

Overview

Loop through every pair of a dictionary, and keep a running total.

Problem Statement

The menu is already in the starter code:

menu = {"tea": 15, "coffee": 25, "sandwich": 60, "cake": 40}

Print every dish and its price on its own line, in the menu's order, in the format tea - 15. Then print what one of each dish costs together, in the format One of each: 140.

Input

No input is required for this question.

Output

tea - 15
coffee - 25
sandwich - 60
cake - 40
One of each: 140

Learn this firstChapter 13 · Loop Through a Dictionary in Python
solution.py
menu = {"tea": 15, "coffee": 25, "sandwich": 60, "cake": 40}
# write your code here

EXPECTED OUTPUT

1tea - 15
2coffee - 25
3sandwich - 60
4cake - 40
5One of each: 140

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.