Open this example in the interactive library
Source code
text = 'Never odd or even'
clean = ''.join(c.lower() for c in text if c.isalnum())
print(clean == clean[::-1])Sample output
True

Check a palindrome. A self-contained example using the Python standard library.
Open this example in the interactive library
text = 'Never odd or even'
clean = ''.join(c.lower() for c in text if c.isalnum())
print(clean == clean[::-1])True