Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- products = {}
- while True:
- product = input().split()
- if 'buy' in product:
- break
- item = product[0]
- price = float(product[1])
- quantity = int(product[2])
- if item not in products:
- products[item] = [price, quantity]
- else:
- if price != products[item][0]:
- products[item][0] = price
- products[item][1] += quantity
- [print(f'{x} -> {(y[0] * y[1]):.2f}') for (x, y) in products.items()]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement