Check whether given string is palindrome or not:
Example:
def palindrome(string):
if string==string[ : : -1]:
return True
else:
return False
print(palindrome("madam"))
print(palindrome("siva"))
print(palindrome("anna"))
Output:
True
False
True
Example:
def palindrome(string):
if string==string[ : : -1]:
return True
else:
return False
print(palindrome("madam"))
print(palindrome("siva"))
print(palindrome("anna"))
Output:
True
False
True
No comments:
Post a Comment