valid palindrome

Go Back home
1 def is_pal(s):
2     sl = [*map(str.lower, filter(str.isalnum, s))]
3     return all([sl[i] == sl[~i] for i in range(len(sl))])
4 
5 print(is_pal("A man, a plan, a canal: Panama"))

See also:

list index complement