0% found this document useful (0 votes)
2 views1 page

Python Palindrome Checker Code

The provided code defines a function 'pali' that checks if a given string is a palindrome. It compares characters from the start and end of the string, printing whether it is a palindrome or not based on the comparisons. The function is then called with user input to demonstrate its functionality.

Uploaded by

Shashank
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Python Palindrome Checker Code

The provided code defines a function 'pali' that checks if a given string is a palindrome. It compares characters from the start and end of the string, printing whether it is a palindrome or not based on the comparisons. The function is then called with user input to demonstrate its functionality.

Uploaded by

Shashank
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Source Code:

def pali(x):
y=len(x)
for i in range(len(x)//2):
y=y-1
if x[i]==x[y]:
continue
else:
print("It's not a palindrome")
break
else:
print("It's a palindrome")
x=input("Enter the string ")
pali(x)

Output:
Enter string:RACECAR
It’s is a Palindrome
Enter string:SCHOOL
It's not a palindrome

You might also like