Advertisement
Guest User

Untitled

a guest
May 2nd, 2025
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. def is_palindrome(word):
  2.     if len(word) == 0:
  3.         return True
  4.     if len(word) == 1:
  5.         return True
  6.    
  7.     if word[0] == word[-1]:
  8.         return is_palindrome(word[1:-1])    
  9.     else:
  10.         return False
  11.    
  12.    
  13. is_palindrome("racecar") # True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement