Advertisement
Maxim_01

Untitled

Jul 25th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. import re
  2.  
  3. regex = r">>([A-Za-z]+)<<([0-9]+\.?[0-9]*)?!(\d+)\b"
  4.  
  5. total_furniture = []
  6. total_price = 0
  7.  
  8. while True:
  9.     command = input()
  10.     if command == "Purchase":
  11.         break
  12.     data = re.findall(regex, command)
  13.     if data:
  14.         furniture, price, count = data[0]
  15.         total_furniture.append(furniture)
  16.         total_price += float(price) * float(count)
  17. print('Bought furniture:')
  18. for i in total_furniture:
  19.     print(i)
  20. print(f"Total money spend: {total_price}")
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement