Safaie Safaie - 1 year ago 122
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


deque import

Answer Source
##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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download