You are given a dictionary consisting of word pairs. Every word is a synonym of the other word in its pair. All the words in the dictionary are different. After the dictionary there's one more word given. Find a synonym for it.

Python
dict = {}
times = int(input())
for _ in range(times):
a = input()
w1, w2 = a.split()
dict[w1] = w2
dict[w2] = w1
print(dict[input()])

How can I further condense this code?

Solved
Show answers

Ask an AI advisor a question