Safaie Safaie - 2 months ago 19
Python Question

Palindrome detector that ignored punctuation marks, spaces and case (python)

This can already detect a Palindrome but i need it to ignored punctuation marks, spaces and case so it can detect something like “A man, a plan, a canal, Panama!”

This is what i already have

first

deque import

Answer
##Rewrite the isPalindrome as added 
def isPalindrome(s):
    deck = Deque()
    for character in s:
        deck.addRear(character.lower()) if character.isalpha() else 0

    while deck.size() > 1:
        if deck.removeFront() !=deck.removeRear():
            return False
    return True