import re user_input = input() #dict_of_names = {} pattern = r"^\%([A-Z][a-z]+)\%[^|$%.]*\<(\w+)\>[^|$%.]*\|(\d+)\|[^|$%.]*?(\d+\.*\d+)\$$" #matches = re.findall(pattern, user_input) #while matches == []: # user_input = input() # matches = re.findall(pattern, user_input) #matches = [x for x in matches[0]] total = 0 while user_input != 'end of shift': if re.search(pattern, user_input) is None: user_input = input() continue matches = re.findall(pattern, user_input) matches = [x for x in matches[0]] #if matches[0] not in dict_of_names.keys(): # dict_of_names[matches[0]] = [matches[1], int(matches[2]), float(matches[3])] #else: # pass #person = matches[0] #total += int(dict_of_names[person][1]) * float(dict_of_names[person][2]) total += int(matches[2]) * float(matches[3]) print( f'{matches[0]}: {matches[1]} - {(int(matches[2]) * float(matches[3])):.2f}') user_input = input() #for person in dict_of_names.keys(): # print( # f'{person}: {dict_of_names[person][0]} - {(int(dict_of_names[person][1]) * float(dict_of_names[person][2])):.2f}') print(f'Total income: {total:.2f}')