LearnPy Hub
← Dictionaries problems
Easy

Swap Keys and Values

Read n lines of key value (n first), build a dictionary, then print the inverted dictionary (values become keys).

Input

n, then n lines.

Output

A dictionary.

Sample 1

Input
2
a 1
b 2
Output
{'1': 'a', '2': 'b'}

Sample 2

Input
1
x y
Output
{'y': 'x'}
solution.py
Output appears here
Swap Keys and Values · Python practice problem · LearnPy Hub