Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- money = {}
- command = input()
- pattern_new = r"([^|$%.]+)?%(?P<name>[A-Z][a-z]+)%([^|$%.]+)?<(?P<product>[a-zA-Z]+)>([^|$%.]+)?\|([^|$%.\d]+)?(?P<quantity>\d+)([^|$%.\d]+)?\|([^|$%.\d]+)?(?P<price>\d+(\.\d+)?)\$([^|$%.]+)?"
- while not command == 'end of shift':
- match = re.match(pattern_new, command)
- if match:
- current_match = match.groupdict()
- money[current_match['name']] = {current_match['product']: int(current_match['quantity']) * float(current_match['price'])}
- command = input()
- total = 0
- for k, v in money.items():
- print(f"{k}: {''.join(f'{kk} - {vv:.2f}' for kk,vv in v.items())}")
- for values in v.values():
- total += values
- print(f'Total income: {total:.2f}')
Advertisement
Add Comment
Please, Sign In to add comment