Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- pattern = r">>(?P<name>[A-Za-z]+)<<(?P<price>\d+\.?\d*)!(?P<quantity>\d+)"
- text = input()
- total = 0
- furniture_name = []
- while not text == 'Purchase':
- match = re.findall(pattern, text)
- if match:
- for i in match:
- furniture_name.append(i[0])
- price = float(i[1])
- quantity = float(i[2])
- total += price * quantity
- text = input()
- print('Bought furniture:')
- for i in furniture_name:
- print(i)
- print(f'Total money spend: ' + "{:.2f}".format(total))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement