Turning Learners Into Developers
Codekilla
CODEKILLA
Medium
PY-003python

Group E-Commerce Orders by Customer

Problem

You're given `n` order lines from an online store. Each line has a customer ID and an amount. Compute the total revenue per customer and print customers in ascending order of ID.

Input
First line: n. Next n lines each: `cust_id amount` (amount is a float).
Output
One line per customer: `cust_id total` (total formatted to 2 decimals), sorted by cust_id ascending.
Constraints
1 ≤ n ≤ 10^5, 0 < amount ≤ 10^6
Sample input
5
101 120.50
102 80.00
101 19.99
103 45.00
102 20.00
Sample output
101 140.49
102 100.00
103 45.00
Explanation
101 → 120.50 + 19.99 = 140.49. 102 → 80 + 20 = 100. 103 → 45.
hash-mapsortingaggregation@Flipkart@Amazon@Zomato
Visible test cases
in: 3
1 10.0
1 20.0
2 5.0
out: 1 30.00
2 5.00
Your solution — run it, use AI if stuck
python