About 218,000 results
Open links in new tab
  1. Recursive Function palindrome in Python - Stack Overflow

    From a general algorithm perspective, the recursive function has 3 cases: 1) 0 items left. Item is a palindrome, by identity. 2) 1 item left. Item is a palindrome, by identity. 3) 2 or more items. Remove first and last item. Compare. If they are the same, call function on what's left of string.

  2. Recursive function to check if a string is palindrome

    May 11, 2025 · Given a string s, the task is to check if it is a palindrome or not. Examples: The idea is to recursively check if the string is palindrome or not. Initialize two pointers: one to point to starting index and one to point to ending index. Compare the …

  3. Palindrome in Python using recursion – allinpython.com

    python program to check for a palindrome string using recursion: if S[L] != S[R] -->false, L >= R --> true, recursive function is_palindrome(L+1, R-1, S)

  4. 5 Best Ways to Check for Palindromes in Python Using Recursion

    Mar 7, 2024 · Method 1 involves a classical recursive function to check if a string is a palindrome. It compares the first and last characters of the string, then proceeds to the next pair, moving inward, by recursively calling itself with a substring excluding these characters.

  5. Python Program to Check If a String is a Palindrome (6 Methods)

    Oct 6, 2021 · In this tutorial, you’ll learn how to use Python to check if a string is a palindrome. You’ll learn six different ways to check if a string is a palindrome, including using string indexing, for loops, the reversed() function. You’ll also learn the limitations of the different approaches, and when one might be better to use than another.

  6. Python Program to Check whether a String is Palindrome or not …

    Here is source code of the Python Program to check whether a string is a palindrome or not using recursion. The program output is also shown below. if len(s) < 1: return True else: if s [0] == s [- 1]: return is_palindrome (s [1:- 1]) else: return False . print("String is a palindrome!") else: print("String isn't a palindrome!") 1.

  7. Python Check Palindrome using Recursive function

    A string is a palindrome if it is identical forward and backward. For example "anna", "civic", "level" and "hannah" are all examples of palindromic words. The following code uses a recursive function to determine whether or not a string is a palindrome.

  8. Python Program to Check if a String is Palindrome or Not

    Feb 21, 2025 · Explanation: is_palindrome(s, i, j) checks if a string is a palindrome by using two pointers, i (left) and j (right). If i >= j, it returns True as all characters matched. If s[i] != s[j], it returns False due to a mismatch. Otherwise, it recursively checks the inner substring with i + 1 and j - 1. Using for loop

  9. python: recursive check to determine whether string is a palindrome

    Jul 16, 2012 · My task is to define a procedure is_palindrome, that takes as input a string, and returns a boolean indicating if the input string is a palindrome. In this case a single letter should return True, as should an empty string '' .

  10. Check if a String is a Palindrome Using Recursion in Python

    Mar 12, 2021 · Learn how to check whether a string is a palindrome using recursion in Python with this detailed guide and example.

Refresh