KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

Write a Python program to accept a string and check if the given string is a palindrome.

Python String Manipulation

3 Likes

Answer

st = input("Enter a string: ")

if st == st[::-1]:
    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: hello
The given string is not a palindrome

Answered By

2 Likes


Related Questions