Question: PYTHON 3 Problem You moved to a new city where people speak a strange language called Nimonese. Fortunately, you have a dictionary that helps you

PYTHON 3

Problem

You moved to a new city where people speak a strange language called Nimonese. Fortunately, you have a dictionary that helps you translate things to normal English. Nimonese only contains N words.

Your objective is to write a program that reads the dictionary entries from stdin, and translates a sentence from Nimonese to English based on the entries in the dictionary. Your program should output the translated sentence to console.

If you try to translate a word that doesn't exist in the dictionary, just replace that word with "eh".

Input

The first line of input is a number, N.

The next N lines are made of two words each. The first word is in English, and the second word is the meaning of that word in Nimonese.

Then there is one more line, containing the sentence you need to translate.

Example Input 1

 
 

7

 

dog ogday cat atcay

 

like aklay pig igpay froot ootfray

 

and danda loops oopslay

 

ogday danda atcay aklay ootfray oopslay

Example Output 1

 
 

dog and cat like froot loops

Example Input 2

 
 

1

 

hello ahoy

 

ahoy boboy

Example Output 2

 
 

hello eh

Hint: if you want to split a line of input by spaces, you can do:

 
 

line = input().split()

 

print(line[0]) # prints the first word in the line

PS: this problem is borrowed from Kattis. Solve it on Kattis and show me for extra points :)

https://open.kattis.com/problems/babelfish

PYTHON 3 Problem You moved to a new city where people speakCODE:

# read N, number of words

N = int(input())?

# read N, number of Words

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!