From 40786b25176e841acdfee153977a687592189f19 Mon Sep 17 00:00:00 2001 From: Ardor Date: Thu, 7 May 2026 13:17:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20cal?= =?UTF-8?q?culate=5Fuser=5Ftotal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zadanie_1.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/zadanie_1.py b/zadanie_1.py index 6bad1a4..7b66bdb 100644 --- a/zadanie_1.py +++ b/zadanie_1.py @@ -57,4 +57,12 @@ def group_by_user(orders: list[dict]) -> dict[int, list[dict]]: if uid not in grouped: grouped[uid] = [] grouped[uid].append(order) - return grouped \ No newline at end of file + return grouped + + +# 4. Расчет общей суммы трат пользователя +def calculate_user_total(user_orders: list[dict]) -> float: + """ + Суммирует все значения 'total' для одного пользователя. + """ + return sum(order['total'] for order in user_orders) \ No newline at end of file