LearnPy Hub
← Dictionaries problems
Hard

Which Lines Use Each Word?

Read n lines of text. Build a dictionary from each lowercase word to the line numbers (from 1) where it appears (each line number once). Print words alphabetically as word: 1 3.

Input

n, then n lines.

Output

Lines.

Sample 1

Input
3
I like tea
Tea is hot
I like it
Output
hot: 2
i: 1 3
is: 2
it: 3
like: 1 3
tea: 1 2

Sample 2

Input
1
a a a
Output
a: 1
solution.py
Output appears here
Which Lines Use Each Word? · Python practice problem · LearnPy Hub