Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python. IN AN HOUR PLZ! (GRADESCOPE SUBMISSION) Write the function translate translation, msg) where translation is a dictionary and msg a string. The dictionary contains
python. IN AN HOUR PLZ!
(GRADESCOPE SUBMISSION) Write the function translate translation, msg) where translation is a dictionary and msg a string. The dictionary contains keys of strings that have a value of another string. Your function will be translating msg using the key-value pairs in the dictionary to create a new string that has replaced all the words in the input string with the words' value in the dictionary. If a word in the string is not in the translation dictionary, the word will retain its original form. You can assume that all the keys in the dictionary are lowercase strings and that msg is a non-empty string with no punctuation. You are not allowed to use the re module or any other methods not covered in this activity Example: + >>> translate({'up': 'down', 'down': 'up'. 'left': 'right', 'right': 'left', '1': 'one'), 'UP down left right for ward 1 time) down up right left forward one time Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started