Q. Write a program that reads a string and checks whether it is a palindrome string or not.
Answer :
string = input("Enter a string :") length = len(string) mid = int(length / 2) rev = -1 for a in range (mid) : if string[a] == string[rev] : a += 1 rev -= 1 else : print(string, "is not a palindrome") break else : print(string, "is a palindrome")
Output :
Enter a string : Pathwalla
Pathwalla is not a palindrome
>>>
Enter a string : madam
madam is a palindrome
>>>
There is no output
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )