Advertisement
Guest User

Untitled

a guest
Mar 24th, 2022
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. line = input().split(" ")
  2. productQuantity = {}
  3. productPrices = {}
  4.  
  5. while "buy" not in line:
  6.     product = line[0]
  7.     price = float(line[1])
  8.     quantity = int(line[2])
  9.  
  10.     if product not in productQuantity.keys():
  11.         productQuantity[product] = 0
  12.         productPrices[product] = 0.00
  13.     productQuantity[product] += quantity
  14.     productPrices[product] = price
  15.     line = input().split(" ")
  16.  
  17.     if "buy" in line:
  18.         break
  19.  
  20. for key, value in productQuantity.items():
  21.     price = value * productPrices[key]
  22.     print(f"{key} -> {price:.2f}")
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement