Skip to content Skip to sidebar Skip to footer

Widget HTML #1

Python Program to Check if a Given String is Palindrome or Not

Python Program to Check if a Given String is Palindrome or Not

Test Case

Test #1
Input String : abcba
abcba is a Palindrome.

Test #2
Input String : abcde
abcba is not a Palindrome.

Source Code

#visit us @hobingoding.com

palindrome = True
string = input("Input String : ")
string = string.lower()
for i in range(0, int(len(string)/2)):
    if(string[i] != string[len(string)-i-1]):
        palindrome = False
        break 
if(palindrome):
    print(string, "is a Palindrome.")
else:
    print(string, "is not a Palindrome.")
Fandi Presly Simamora
Fandi Presly Simamora Do it right, be bright.

Post a Comment for "Python Program to Check if a Given String is Palindrome or Not"