Advertisement
viligen

orders

Nov 6th, 2021
867
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. order = {}
  2. total_price = 0
  3.  
  4. while True:
  5.     data = input().split()
  6.     if "buy" in data:
  7.         break
  8.     product = data[0]
  9.     price = float(data[1])
  10.     quantity = int(data[2])
  11.  
  12.     if product not in order:
  13.         order[product] = [price, quantity]
  14.     else:
  15.         order[product][1] += quantity
  16.         order[product][0] = price
  17.  
  18. for k, v in order.items():
  19.     total_price = v[0]*v[1]
  20.     print(f"{k} -> {total_price:.2f}")
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement