fork download
  1. import re
  2. strings = [
  3. "race a car",
  4. "A man, a plan, a canal: Panama"
  5. ]
  6.  
  7. for s in strings:
  8. s = re.sub(r"[^a-zA-Z0-9]+", "", "".join(s).lower())
  9. if s == s[::-1]:
  10. print("true: for {0}".format(s))
  11. else:
  12. print("false: for {0}".format(s))
Success #stdin #stdout 0.03s 9292KB
stdin
Standard input is empty
stdout
false: for raceacar
true: for amanaplanacanalpanama