Advertisement
DannyDonkov

Untitled

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