Skip to content
Advertisement

How can I write with a translator’s dictionary?

This is how my program is structured:

There is an n in the first line of the input that indicates the number of words in the translation dictionary. Each of the next n lines contains four words, the second to fourth words being the translation of the first word. Each word is translated into three different languages. The second word is the English translation, the third word is the French translation, and the fourth word is the German translation of the first word. The last line contains a sentence that needs to be translated from one of the English, French or German languages ​​into the first word. A sentence consists of several words separated by a space.

input:

JavaScript

Correct output:

JavaScript

my code:

JavaScript

My code has a problem and shows a wrong output. Please help me to correct the code and display it according to the sample output.

Advertisement

Answer

dict(input().split(' ') for i in range(tedad)) is not compatible with the inputs you give with not 2 words per line

One way can be from your code :

JavaScript

having that in the file p.py and the input in i :

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement