Python One Line Code To Check Palindrome

We can check whether a given string is palindrome or not just in one line of code in python. A palindrome is a number, words, phrase, or other collection of characters which reads the same from backward as forward.

Palindrome Examples: madam, radar, rotator, step on no pets, 1221 etc.

Python Source Code: Palindrome Check (One Line)


string = input('Enter anything: ')

print('PALINDROME') if string == string[::-1] else print('NOT PALINDROME')

Output

RUN 1:
-----------------
Enter anything: rotator
PALINDROME

RUN 2:
-----------------
Enter anything: Hello
NOT PALINDROME