Question: 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

 python please. musy have KeyError and include invalid input and invalidpython 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

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!