← Python from Scratch
Lesson 40 of 78 · 5 XP
Warm-up: prices in a dictionary warm-up
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
A dictionary stores "key → value" pairs. You get a value by its key in square brackets:
prices = {"apple": 50, "banana": 30}
print(prices["banana"]) # 30
Task. The starter code already has a dictionary of prices. Read the name of a fruit and print its price.
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.