Robotics & Artificial Intelligence

Write a Python program to check that a given string is a palindrome or not.

Python String Manipulation

3 Likes

Answer

string1 = input("Enter a string: ")
rev = string1[::-1]

if string1 == rev:
    print("The given string is a palindrome")
else:
    print("The given string is not a palindrome")

Output

Enter a string: madam
The given string is a palindrome

Enter a string: computer
The given string is not a palindrome

Answered By

2 Likes


Related Questions