Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## detect palindromes in python
- ## does not take into account whitespaces, uppercases/lowercases
- def is_palindrome (uString):
- l = len (uString)
- if l == 0 or l == 1: return True
- elif uString[0] == uString[-1]: return is_palindrome (uString[1:-1])
- else: return False
- if __name__ == "__main__":
- print is_palindrome ("racecar")
- print is_palindrome ("2002")
- print is_palindrome ("not-a-palindrome")
Advertisement
Add Comment
Please, Sign In to add comment