Question: Using Python! Activity 0: Palindromes [Palindromes] are phrases that read the same forwards and backwards (ignoring whitespace and punctuation). The phrase taco cat is an
Activity 0: Palindromes [Palindromes] are phrases that read the same forwards and backwards (ignoring whitespace and punctuation). The phrase "taco cat" is an example of a palindrome. For this activity, you are to implement a function named isRaliadcoue: det isapalindcome(s, case sensitive-False): Returns whether or not a string is a palindrome" Given a string s, this function determines whether or not s is a palindrome. If the parameter sase sensitive is True, then the letters much match exactly, otherwise the function should ignore differences in case (lower vs upper) Once you have defined the function, you should be able to do the following: True >>> ispalindreme( Taco cat', True) False Hints The following are hints and suggestions that will help you complete this activity 1. To make comparing letters easier, pre-process the input by removing all whitespace and punctuation from the string before performing the comparison. 2. Opawax to ignore case when cas seRsitieis False is to convert the string to one case. Determine what exactly needs to be compared. Do you need a loop and if so, what should be compared in each iteration? Could you utilize slices or other list and string methods to help you solve this problem? 3. Note, there is more than one way to implement this function; the important thing is that you come up with a strategy that you understand and can implement effectively
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
