Loading...
Loading...
Loading...
A warehouse sends its stock list: one line per product with its SKU and quantity. If a SKU appears twice, the later line is the current stock. Then someone asks about one SKU.
Print its quantity, or Not found if the SKU is not in the list.
Not found.Example 1
Input
3 pen 40 book 12 bag 7 book
Output
12
The SKU is in the list.
Example 2
Input
2 pen 40 book 12 cable
Output
Not found
The SKU is missing.
Try the problem first. Open one hint at a time.
Store each SKU and its quantity in a dictionary as you read the lines.
Assigning to an existing key replaces its value, which handles the repeated SKU. Use get with a fallback for the lookup.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor