LearnPy Hub
← Dictionaries problems
Hard

Sales by Region and Product

Read n lines region product amount. Build a nested dictionary and print, for each region in alphabetical order, the region name and then each product (alphabetical) with its total, indented by two spaces.

Input

n, then n lines.

Output

Lines.

Sample 1

Input
4
Dhaka Tea 100
Sylhet Tea 50
Dhaka Rice 30
Dhaka Tea 20
Output
Dhaka
  Rice 30
  Tea 120
Sylhet
  Tea 50

Sample 2

Input
1
X Y 1
Output
X
  Y 1
solution.py
Output appears here
Sales by Region and Product · Python practice problem · LearnPy Hub