Advertisement
pacho_the_python

Orders

Mar 14th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. command = input().split(" ")
  2.  
  3. product_dict = {}
  4.  
  5. while True:
  6.     if command[0] == "buy":
  7.         break
  8.  
  9.     item = command[0]
  10.     price = float(command[1])
  11.     current_quantity = int(command[2])
  12.  
  13.     if item not in product_dict:
  14.         product_dict[item] = [price, current_quantity]
  15.     else:
  16.         product_dict[item] = [price, (product_dict[item][1] + current_quantity)]
  17.  
  18.     command = input().split(" ")
  19.  
  20. for i in product_dict:
  21.     total = product_dict[i][0] * product_dict[i][1]
  22.     print(f"{i} -> {total:.2f}")
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement