LearnPy Hub
← Comprehensions problems
Hard

Index of Words

Read a sentence and print a dictionary mapping each distinct word (lower case) to the sorted list of positions where it appears.

Input

One line.

Output

A dictionary.

Sample 1

Input
the cat and the hat
Output
{'the': [0, 3], 'cat': [1], 'and': [2], 'hat': [4]}

Sample 2

Input
a
Output
{'a': [0]}
solution.py
Output appears here
Index of Words · Python practice problem · LearnPy Hub