LearnPy Hub
← Async Basics problems
Medium

Fetch Prices Together

async def price(item) awaits a short sleep and returns the item's price from {'tea': 20, 'rice': 70, 'oil': 180} (0 if unknown). Read items and use asyncio.gather to get all prices at once. Print a dictionary item → price, and then the total.

Input

One line of items.

Output

Two lines.

Sample 1

Input
tea rice
Output
{'tea': 20, 'rice': 70}
90

Sample 2

Input
oil
Output
{'oil': 180}
180
solution.py
Output appears here
Fetch Prices Together · Python practice problem · LearnPy Hub