In [11]:
from pythonds9.basic.deque import Deque
import string
In [14]:
def pal_checker(a_str):
    char_deque = Deque()
    
    a_str = a_str.lower()
    
    for ch in a_str:
        if ch in string.ascii_lowercase:
            char_deque.add_rear(ch)
        
    still_equal = True
    
    while char_deque.size() > 1 and still_equal:
        first = char_deque.remove_front()
        last = char_deque.remove_rear()
        if first != last:
            still_equal = False
            
    return still_equal
In [15]:
pal_checker("kfhgsdkjfhksdjf")
Out[15]:
False
In [16]:
pal_checker("radar")
Out[16]:
True
In [17]:
pal_checker("Mr. Owl ate my metal worm")
Out[17]:
True
In [18]:
pal_checker("Do geese see God?")
Out[18]:
True
In [19]:
pal_checker("Anna")
Out[19]:
True
In [20]:
pal_checker("noon")
Out[20]:
True