Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def isPalindrome(string):
- rev_string = string[::-1]
- return string == rev_string
- def isPalindrome2(string):
- rev_string = ''.join(reversed(string))
- return string == rev_string
- def isPalindrome3(string):
- left, right = 0, len(string) - 1
- while right >= left:
- if not string[left] == string[right]:
- return False
- left += 1
- right -= 1
- return True
- print(isPalindrome('redrum murder'))
- print(isPalindrome2('redrum murder'))
- print(isPalindrome3('redrum murder'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement