Dremendo Tag Line

Input word and check palindrome word or not in Python

String Methods - Question 3

In this question, we will see how to input a word and check if it is a palindrome word or not in Python programming. To know more about string methods click on the string methods lesson.

Q3) Write a program in Python to input a word and check if it is a palindrome word or not.

Program

rev=""
str=input("Enter a word\n")

for i in range(0,len(str)):
    rev=str[i]+rev

if str.upper()==rev.upper():
    print('Palindrome word')
else:
    print('Not palindrome word')

Output

Enter a word
Madam
Palindrome word
video-poster