Question: For python In the real world and common usage, a physical dictionary is a collection of words matched with their definitions. Given a word, you
For python
In the real world and common usage, a physical dictionary is a collection of words matched with their definitions. Given a word, you can look up its definition in a dictionary. Write a function that will take a dictionary and a list of words in English and return a translated version of the list. If any word is not found in the dictionary, you do not need to translate it and just add it to the list as is. The dictionary's keys will be the word in English and its values are the translated verion. The function should: be named translate() take two arguments, a dictionary and a list of words return a list with translated words # YOUR CODE HERE Graded Read Only input_string = "hello world my first program" spanish = dict() spanish['hello'] = 'hola' spanish['yes'] = 'si' spanish['first'] = 'primer spanish['two'] = 'dos' spanish['world'] = 'mundo' spanish['red'] = 'rojo' spanish['black'] = 'negro spanish['green'] = 'verde spanish['my'] = 'mi' str_result = print(input_string, " ", ' '.join([str(elem) for elem in translate(spanish, list(input_string.split(" "))))))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
