LearnPy Hub
← Pandas: Cleaning & Preprocessing problems
Hard

Change From Month to Month

Total the amounts per month (YYYY-MM) in order. Print each month with its total and the percentage change from the previous month (1 decimal, with a sign like +12.5% or -3.0%); the first month shows -.

Input

Lines 'date region product amount', then END.

Output

Lines.

Sample 1

Input
2026-01-15 Dhaka Tea 500
2026-01-20 Sylhet Tea 300
2026-02-03 Dhaka Rice 1200
2026-02-18 Khulna Tea 450
2026-03-07 Sylhet Rice 800
2026-03-21 Dhaka Tea 650
END
Output
2026-01 800 -
2026-02 1650 +106.2%
2026-03 1450 -12.1%

Sample 2

Input
2026-05-01 Dhaka Tea 100
END
Output
2026-05 100 -
solution.py
Output appears here
Change From Month to Month · Python practice problem · LearnPy Hub