Q. Write a Python function that checks whether a passed string is a palindrome or not.
Answer =
def check(x) :
if x[ -1 : - len(x) - 1 : - 1] == x:
print ("String is a palindrome.")
else :
print ("String is not a palindrome ")
string = input ("Enter a String :- ")
check(string)
Output :-
Enter a String :- abcdcba
String is a palindrome.
>>>
Enter a String :- computer
String is not a palindrome
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )