A palindrome is a sequence that reads the same in either direction.
Here is function I wrote to check if a phrase is a palindrome:
import re def is_palindrome(txt): txt = re.sub('\W+', '', txt).lower() return txt == txt[::-1]
phrase = "Go hang a salami, I'm a lasagna hog" print is_palindrome(phrase) >> True
Copyright © 2006-2008 Corey Goldberg
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.