Advertisement
bl00dt3ars

05. Orders

Aug 6th, 2021
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. products = {}
  2. line = input()
  3.  
  4. while not line == "buy":
  5.     product, price, value = line.split()
  6.     if product not in products:
  7.         products[product] = [float(price), int(value)]
  8.     else:
  9.         products[product][1] += int(value)
  10.         products[product][0] = float(price)
  11.     line = input()
  12.  
  13. [print(f"{k} -> {v[0] * v[1]:.2f}") for k, v in products.items()]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement