Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- command = input()
- total_sum = 0
- list_of_products = {}
- while command != "end of shift":
- pattern = r'(%([A-Z][a-z]+)%)(\w*)(<(\w+)>)(\w*)(\|([0-9]+)\|)(\D*)((\d.+)(\$))'
- matches = re.finditer(pattern, command)
- for match in matches:
- name = match.group(2)
- product = match.group(5)
- quantity = int(match.group(8))
- price = match.group(11)
- total_sum += quantity * float(price)
- current_sum = quantity * float(price)
- list_of_products[name] = [product, current_sum]
- command = input()
- for key, values in list_of_products.items():
- name = key
- product = values[0]
- price = values[1]
- print(f"{name}: {product} - {price:.2f}")
- print(f"Total income: {total_sum:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment