Saturday, 9 September 2017

how to check given string is palindrome or not

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

No comments:

Post a Comment