Python 3 Script to Check if given String is Palindrome or Not Using Recursion Full Project For Beginners

Python 3 Script to Check if given String is Palindrome or Not Using Recursion Full Project For Beginners

 

Welcome folks today in this post we will be checking if given string is palindrome or not using recursion in python. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

app.py

 

 

def isPalRec(st, s, e) : 
    
    if (s == e): 
        return True

    # If first and last 
    # characters do not match 
    if (st[s] != st[e]) : 
        return False

    if (s < e + 1) : 
        return isPalRec(st, s + 1, e - 1); 

    return True

def isPalindrome(st) : 
    n = len(st) 
    
    # An empty string is 
    # considered as palindrome 
    if (n == 0) : 
        return True
    
    return isPalRec(st, 0, n - 1); 



st = input("Enter the Input String to Check for Palindrome:")
if (isPalindrome(st)) : 
    print("Yes this is a palindrome string")
else : 
    print("No this is not a palindrome string")

 

See also  Python 3 FFMPEG Script to Generate Animated Video GIF Maker Based on TimeStamp Full Project For Beginners

 

Now if you execute the python script app.py by typing the below commnad

 

python app.py

 

 

As you can see we are taking the input string by user and then we are checking for palindrome string using recursion method. As you can see bob word is palindrome string

Leave a Reply