Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def palindrome(word, idx):
- if idx == len(word):
- return f"{word} is a palindrome"
- elif word[-idx - 1] == word[idx]:
- return palindrome(word, idx + 1)
- else:
- return f"{word} is not a palindrome"
- print(palindrome("peter", 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement