Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- pattern = r">>([a-zA-Z]+)<<(\d+\.?\d*)!(\d+)\b"
- bought_furniture = []
- total_sum = 0
- while True:
- line = input()
- if line == "Purchase":
- break
- match = re.search(pattern, line)
- if match:
- product, price, quantity = match.groups()
- bought_furniture.append(product)
- total_sum += float(price) * int(quantity)
- print("Bought furniture:")
- for each in bought_furniture:
- print(each)
- print(f"Total money spend: {total_sum:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement