Добавлена функция calculate_user_total

This commit is contained in:
Антон Репин 2026-05-07 13:17:24 +03:00
parent e68ebc4130
commit 40786b2517

View File

@ -58,3 +58,11 @@ def group_by_user(orders: list[dict]) -> dict[int, list[dict]]:
grouped[uid] = []
grouped[uid].append(order)
return grouped
# 4. Расчет общей суммы трат пользователя
def calculate_user_total(user_orders: list[dict]) -> float:
"""
Суммирует все значения 'total' для одного пользователя.
"""
return sum(order['total'] for order in user_orders)