Question: Write a function named is _ palindrome that accepts a string parameter and returns True if that string is a palindrome, or False if it
Write a function named ispalindrome that accepts a string parameter and returns True if that string is a palindrome, or False if it is not a palindrome.
For this problem, a palindrome is defined as a string that contains exactly the same sequence of characters forwards as backwards, caseinsensitively. For example, "madam" or "racecar" are palindromes, so the call of ispalindromeracecarwould return True. Spaces, punctuation, and any other characters should be treated the same as letters so a multiword string such as "dog god" could be a palindrome, as could a gibberish string such as $$ The empty string and all onecharacter strings are palindromes by our definition. Your code should ignore case, so a string like "Madam" or "RACEcar" would also count as palindromes.
import string
def ispalindromes:
s joinc for c in s if c not in string.punctuation
if lensvarnothing:
return True
if lens:
return True
return s s::
Attached is my code. I can't figure out how to pass the th test.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
