Skip to content

Commit

Permalink
Merge pull request #1 from pierrerousseau/palindrome-patch-1
Browse files Browse the repository at this point in the history
another way to test a plalindrome
  • Loading branch information
pierrerousseau committed Apr 9, 2015
2 parents eb63201 + e453810 commit f547080
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions palindrome.py
@@ -1,3 +1,9 @@
def palindrome(x):
x = str(x)
return len(x) < 2 or (x[0] == x[-1] and palindrome(x[1:-1]))

def is_palindrome(word):
""" :returns: True if <word> is a palindrome
:param str word: a string
"""
return word == word[::-1]

0 comments on commit f547080

Please sign in to comment.