Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedCODE:

# read N, number of words

N = int(input())?

# read N, number of Words

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

What are the three logical steps of the cash disbursements system?

Answered: 1 week ago