Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function that translates an English sentence to leetspeak. Hints: You will want to turn your sentence into a list of words, replace those,
Write a function that translates an English sentence to leetspeak. Hints: You will want to turn your sentence into a list of words, replace those, and then turn it back into a sentence before replacing letters. To turn a list of words into a sentence, you can use the syntax: new_sentence = " ".join(old_list) This will join all the values in "old list" into a string, separated by spaces. If you want to determine if a word is in your dictionary, use "if word in dictionary.keys0" You may assume that the sentences are, much like YouTube comments, devoid of any punctuation or capitalization. Use the following general algorithm: Replace the following words: elite -> leet the -> teh hacker -> haxor hack -> hax own -> pwn owned -> pwned dude -> dood rocks -> roxxorz awesome -> awezome internet -> teh tubes ever -> evarr 1md3 -> most awesome course ever If any word ends with an 's', replace it with a 'z' Replace the following letters: . a -> "@" -> "3" . t-> "7" . 1 -> "1" .0-> "0" S -> "$" Replace the words before replacing the letters, so that the replaced words will have the replaced letters In [ ]: def leet(s): # 'Pri7h33 7@k3 3@rn3$7 3ff0r7 70 p1@c3 $uch wordz in $uffici3n7 3nvironz 70 3x3mplify 73h m0$ 7_ @fflu3n7 Of in 73113c7u@1 return stuff In [ ]: print("How'd I do?!") print("#1 - ", leet("I'm very well acquainted too with matters mathematical") == "I'm v3ry w311 @cqu@in73d 700 wi7h m@ 77 print("#2 - , leet("I understand equations both the simple and quadratical") == "I und3r$7@nd 3 qu@ 7i0nz b07h 73h $imp13 print("#3 - ", leet("About binomial theorem I'm teeming with a lot of news") == "Abou7 binomi@1 7h30r3m I'm 733ming wi7h print("#4 - ", leet("With many cheerful facts about the square of the hypotenuse!") == "Wi7h m@ny ch33rful f@c7z @b0u7 7
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