Skip to content

Instantly share code, notes, and snippets.

@eigenn
Created July 10, 2013 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eigenn/5970091 to your computer and use it in GitHub Desktop.
Save eigenn/5970091 to your computer and use it in GitHub Desktop.
Python finding palindromes
"""
Python palidrome finders.
3 methods for finding palindromes with python.
"""
def is_palindrome_v1(s):
if len(s) <= 1:
return True
else:
return s[0] == s[-1] and is_palindrome_v1(s[1:-1])
is_palindrome_v2 = lambda s: s == s[::-1]
def is_palindrome_v3(s):
return s == ''.join(reversed(s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment