The price of an item
Task
The program has a dictionary cennik (price list). It reads the name of an item and prints its price. If the item is not in the price list, it prints Tovar nemáme. (we do not have it).
Handle the missing key with try and except KeyError - not with a condition or the get method.
Examples
Input
maslo
Expected output
2.49
Input
pivo
Expected output
Tovar nemáme.
Rules
Handle the missing key with
except KeyError.Use
tryandexcept- noifand noget.
After you submit, 3 hidden tests will also check your solution: another item, a capital first letter, empty input.
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.