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
3 Likes
Related Questions
Write a Python program to check that a given string contains only alpha numeric characters. If user is not entering alphanumeric characters prompt him or her to enter it again.
Write a Python program for the following task:
Take a string entered by the user and check if it begins with the letter "a" or not. If it begins with "a", the user is prompted that it is the first name on the list. If it does not begin with "a", the user is prompted that the string does not begin with the letter "a".
Write a Python program to reverse a string.
Take a string and create a substring that contains all the unique characters from the list.