Respuesta :
Answer:
To add values to a dictionary, specify the dictionary name with the key name in quotes inside a square bracket and assign a value to it.
dictionary_name["key_name"] = value
Explanation:
A python dictionary is an unindexed and unordered data structure. It's items a key-value pair separated by a colon and the entire dictionary items are enclosed in curly braces. Unlike a list, the dictionary does not use an index but uses the key to get or add a value to the dictionary.
Answer:
Python answer:
dict = {}
times = int(input())
for _ in range(times):
a = input()
w1, w2 = a.split()
dict[w1] = w2
dict[w2] = w1
print(dict[input()])
Explanation:
Intialize your dictionary.
Ask for how many keys you will be adding to the dictionary.
Over a for loop, take an input of keys and values and split them and add them to the dictionary.
I set the key as a value and a variable due to the fact that we are working with synonyms and if the user inputs a synonym that is only the value, we can't get another synonym out. Therefore it is better if we make each word a key and a value.
Then print a synonym of whatever the user inputs.