SoftUni Bar Income
Условие(Задача 2): https://softuni.bg/trainings/resources/officedocument/52671/regular-expressions-more-exercise-python-fundamentals-september-2020/3132
Решение: https://pastebin.com/SVb1T8qU
Условие(Задача 2): https://softuni.bg/trainings/resources/officedocument/52671/regular-expressions-more-exercise-python-fundamentals-september-2020/3132
Решение: https://pastebin.com/SVb1T8qU
import re
text = input()
income = 0
while not text == "end of shift":
matches = re.search(r"(\%[A-Z][a-z]+\%)([^\|\$\%\.]*?)(\<\w+\>)([^\|\$\%\.]*?)(\|[0-9]+\|)([^\|\$\%\.]*?)([0-9.]+[0-9])(?=\$)", text)
if matches:
name = matches.group(1)[1:-1]
product = matches.group(3)[1:-1]
count = int(matches.group(5)[1:-1])
price = float(matches.group(7))
amount = count * price
income += amount
print(f"{name}: {product} - {amount:.2f}")
text = input()
print(f"Total income: {income:.2f}")