Advertisement
pacho_the_python

Untitled

Mar 22nd, 2022
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import re
  2.  
  3. text = input()
  4. total = 0
  5. pattern = r"%([A-Z][a-z]+)%<(\w+)>\|(\d+)\|(\d+\.\d+)\$"
  6.  
  7. while True:
  8.     if text == "end of shift":
  9.         break
  10.     result = re.findall(pattern, text)
  11.     if result:
  12.         for i in result:
  13.             name = i[0]
  14.             item = i[1]
  15.             bill = int(i[2]) * float(i[3])
  16.             total += bill
  17.             print(f"{name}: {item} - {bill:.2f}")
  18.  
  19.     text = input()
  20. print(f"Total income: {total:.2f}")
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement