Advertisement
pacho_the_python

Untitled

Mar 19th, 2022
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import re
  2.  
  3. data = input()
  4.  
  5. money_spend = 0
  6. furniture_list = []
  7.  
  8. while True:
  9.     if data == "Purchase":
  10.         break
  11.  
  12.     pattern = r">>([a-zA-Z]+)<<(\d+|\d+\.\d+)!(\d+)"
  13.  
  14.     furniture_data = re.match(pattern, data)
  15.  
  16.     if furniture_data is not None:
  17.         furniture = furniture_data[1]
  18.         price = float(furniture_data[2])
  19.         quantity = float(furniture_data[3])
  20.         furniture_list.append(furniture)
  21.         money_spend += price * quantity
  22.  
  23.     data = input()
  24.  
  25. print("Bought furniture:")
  26.  
  27. for i in furniture_list:
  28.     print(i)
  29.  
  30. print(f"Total money spend: {money_spend}")
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement