Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- regex = r"^>>([A-Za-z]+)<<([0-9]+)(\.[0-9]+)?!([0-9]+)\b"
- furniture = []
- prices = []
- while True:
- command = input()
- if command == "Purchase":
- break
- data = re.findall(regex, command)
- if data:
- furniture.append(data[0][0])
- price = f"{data[0][1]}{data[0][2]}"
- total_price = float(price) * float(data[0][3])
- prices.append(total_price)
- print('Bought furniture:')
- for i in furniture:
- print(i)
- print(f"Total money spend: {sum(prices)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement