Write a python program to calculate the length of a string using recursion and check whether the given number is palindrome or not.

def length(str1):

    if str1=="":

        return 0

    else:

        return length(str[1:-1])

str1=input("Enter the  Data:")

print("The Length of the Data:",len(str1))

if str1==str1[::-1]:

    print("The Given Data:",str1, "is Palindrome")

else:

    print("The Given Data:",str1, "is not Palindrome")

          


Comments

Popular posts from this blog

Write a python program to compute cumulative product of a list of numbers (write function cumulative_product).

Write a Python program to compute distance between two points taking input from the user. Formula for Pythagorean theorem for compute distance between two points is: