Advertisement
Maxim_01

Untitled

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