str='level'
str_rev=''.join(reversed(str))
if(str==str_rev):
print("The string ",str," is a Palindrome ")
else:
print("The string ",str," is NOT a Palindrome ")
Output
The string level is a Palindrome
str='plus2net'
n=len(str) # length of the string
x=''
for i in range(n-1,-1,-1):
#print(str[i],end='')
x=x+str[i]
if(x==str):
print(" \n The string ",str," is a Palindrome ")
else:
print("\n The string ",str," is NOT a Palindrome ")
Output
The string plus2net is NOT a Palindrome

str=input("Enter a string: ")
str_rev=str[::-1]
if(str_rev==str):
print(" \n The string ",str," is a Palindrome ")
else:
print("\n The string ",str," is NOT a Palindrome ")
Output
Enter a string: radar
The string radar is a Palindrome
str=input("Enter any string : ")
x=''
for i in str:
x=i+x
if(x==str):
print(" \n The string ",str," is a Palindrome ")
else:
print("\n The string ",str," is NOT a Palindrome ")
Output
Enter any string : malayalam
The string malayalam is a Palindrome
str=input("Enter a string: ")
str1=str.upper()
str_rev=str1[::-1]
if(str_rev==str1):
print(" \n The string ",str," is a Palindrome ")
else:
print("\n The string ",str," is NOT a Palindrome ")
Output
Enter a string: Radar
The string Radar is a Palindrome
All String methods
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.