Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python please. musy have KeyError and include invalid input and invalid word Consider the following dictionary which stores a list of word pairs for translating

image text in transcribedpython please. musy have KeyError and include invalid input and invalid word
Consider the following dictionary which stores a list of word pairs for translating English words to French words: dictionary = {"house':'maison', 'apple' 'yellow':'jaune', 'keyboard':'clavier city':'ville', 'ear':'oreille', 'eel' Write a function called get_french_word (word_dictionary, word) that takes such a dictionary and a word as parameters. The function should return the French word that corresponds to the parameter English word. If the English word does not appear in the dictionary, then your function should return an error message to indicate that the particular word is not available. If the word is an empty string, the function should return the error message "ERROR: Invalid word!". If the word is of an invalid type, the function should return the error message "ERROR: Invalid input!". Note: you *must* use the try... except syntax and handle the KeyError in your solution. You can assume that the dictionary is given. For example: Test print(get_french_word (dictionary, 'hou print (get_french_word (dictionary, 'ora print (get_french_word (dictionary,"")) print(get TTRICHIWUTTUICTIOnary, 2.5)

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

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

2. How can speakers enhance their credibility?

Answered: 1 week ago