Dict and Set Comprehensions

Lab Python Intermediate 20 points

Read a line of words. Print a dict mapping each word to its length (using a dict comprehension), then the sorted set of first letters (using a set comprehension).

Input

One line.

Output

Two lines.

Example

Input

apple banana avocado

Output

{'apple': 5, 'banana': 6, 'avocado': 7}
['a', 'b']
Sample input available Sample output available
Editor
Python

Hints

{k: v for ...} builds a dict; {x for ...} builds a set.

Solution explanation

All four comprehension types share the same syntax: list, dict, set and generator.

Show solution
words = input().split()
print({w: len(w) for w in words})
print(sorted({w[0] for w in words}))
Output
Answer
HOME LEARN COMMUNITY DASHBOARD