44.4k views
0 votes
Implement function translate() that provides a rudimentary translation service. The function input is a dictionary mapping words in one language (the first language) to corresponding words in another (the second language). The function provides a service that lets users type a phrase in the first language interactively and then obtain a translation into the second language, by pressing the Enter/Return key. Words not in the dictionary should be translated as __

User MadhaviJ
by
6.5k points

1 Answer

3 votes

Answer:

Check the explanation

Step-by-step explanation:

#method to find the word in one language and return

#corresponding word in other language

def translate(ltolDict):

#loop to display contents of the dictionary

print("Welcome to the WordsRUs translation service.")

word = input("Please enter a word: ")

while word != "Quit" and word != "quit":

if word in ltolDict:

print(word ," means ", ltolDict[word])

else:

print(word ," means ", "________")

word = input("Please enter a word: ")

print("Thanks for using our translation service.")

A code screenshot can be seen below.

Implement function translate() that provides a rudimentary translation service. The-example-1
User KEND
by
7.4k points