Question: PYTHON PLEASE Complete the function spongebobify, which takes a sentence and spongebobifies it (well, sort of), that is, changes the letters into alternating case, starting
PYTHON PLEASE
Complete the function spongebobify, which takes a sentence and "spongebobifies" it (well, sort of), that is, changes the letters into alternating case, starting with two uppercase letters, followed by three lowercase letters, and so on. Non-letters should be ignored. You'll want to explore the isalpha function, which returns True if a given character is a letter or not, and False otherwise. Hint: you need to find a way to keep track of whether the next letter should be uppercase or lettercase which doesn't depend merely on the index of the letter in the string. For instance, the string 'spongebobify this sentence' should be transformed into SPongeBobiFY this sentence not SpongeBobiFY this sentence In the latter (incorrect) attempt, only the index of each character is used to decide whether to use uppercase or lowercase letters, which is the wrong approach. Examples Function Call Return value 'SpongEBobify this Sentence' spongebobify('spongebobify this sentence') spongebobify( 'hello there') 'Hello There' spongebobify('HEIDE LBERG univeRSITY 2021 yeah!') spongebobify('Oh, It's Days Like This That Make Me Wish I Had Gone To College.') 'HeIde lBerg UnIVErSiTy 2021 YeAh!' 'Oh, it's Days like this that Make ME wish I had gone to college.' [1] def spongebobify( sentence)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
