"""
Created on Sun Oct  5 21:50:07 2025
@author: vila
"""
    
def cafeta_total_update(total_drink, total_food, item, drinks, foods):
    units, prod, price  = item.split(' ')
    units = int(units)
    price = float(price)
    value = units*price
    if prod in drinks:
        total_drink += value
    elif prod in foods:
        total_food += value
    else:
        pass
    return total_drink, total_food

def cafeta_total_calc(s, drinks, foods):
    t_drink = t_food = 0.0

    p1, p2, p3, p4 = s[:-1].split(', ')
    t_drink, t_food = cafeta_total_update(t_drink, t_food, p1, drinks, foods)
    t_drink, t_food = cafeta_total_update(t_drink, t_food, p2, drinks, foods)
    t_drink, t_food = cafeta_total_update(t_drink, t_food, p3, drinks, foods)
    t_drink, t_food = cafeta_total_update(t_drink, t_food, p4, drinks, foods)
    
    sout = 'The drinks total is {}€ and the foods total is {}€.'
    return sout.format(round(t_drink, 2), round(t_food, 2))
