Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- pattern = r"%([A-Z][a-z]+)%[^|$%]*<(\w+)>[^|$%]*\|(\d+)\|[^|$%0-9]*(\d+(\.\d*)?)\$$"
- total_income = 0
- while True:
- data = input()
- if data == "end of shift":
- break
- matches = re.finditer(pattern, data)
- name = ""
- product = ""
- count = 0
- price = 0
- for match in matches:
- if match.group(1) and match.group(2) and match.group(3) and match.group(4):
- name = match.group(1)
- product = match.group(2)
- count = int(match.group(3))
- price = float(match.group(4))
- print(f"{name}: {product} - {count * price:.2f}")
- total_income += count * price
- print(f"Total income: {total_income:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement