LearnPy Hub
← Pandas: Cleaning & Preprocessing problems
Medium

Clean Messy Text

Read city names until END; they have extra spaces and mixed case. Clean them with .str.strip().str.title() and print each distinct city with its count, alphabetical.

Input

Lines, then END.

Output

Lines.

Sample 1

Input
  dhaka
Sylhet 
DHAKA
khulna
END
Output
Dhaka 2
Khulna 1
Sylhet 1

Sample 2

Input
x
END
Output
X 1
solution.py
Output appears here
Clean Messy Text · Python practice problem · LearnPy Hub