CJCoding With Joseph
15free / daySign inCreate account

Order Total From A Menu

Price a whole order against a menu you declare yourself as the dict {'coffee': 2.5, 'bagel': 1.75, 'soup': 4.0}. Input: the first line is a whole number n, then n pairs of lines, an item name and then a quantity as a whole number; read them with a bare input(), no prompts, using range(n). For each pair use in to check the key first: an item on the menu adds its price times the quantity to a running total, while an unknown item prints Unknown item: <name> immediately and adds nothing. After the last pair print Total: <value> with two decimals. Output: one line per unknown item, in input order, then the total line.

Expected Output:

Unknown item: cake
Total: 9.00

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Dictionaries
📥 Auto-Input:
3\ncoffee\n2\ncake\n1\nsoup\n1\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.