Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

check palindrome in python using recursion

def isPalindrome(string):
  	#termination condition: the string is one character or less
    if (len(string) <= 1):
        return True
    if (string[0] == string[-1]):
        return isPalindrome(string[1:-1])
    else:
        return False
Comment

palindrome of a number in python using recursion

def reverse(n, rev=0):
    if n == 0:
        return rev 
    rev = rev * 10 + (n % 10)
    rev = reverse(n // 10, rev)
    return rev
n = int(input("Enter a no.:"))
if n == reverse(n):
    print(n,' is a Palindrome')
else:
    print(n,' is not a Palindrome')
Comment

PREVIOUS NEXT
Code Example
Python :: images subplot python 
Python :: easy sending email python 
Python :: value count a list python 
Python :: rotate image pyqt5 
Python :: python tkinter fullscreen 
Python :: python list add if not present 
Python :: python convert 1 to 01 
Python :: pandas sort columns by name 
Python :: discord.py create text channel 
Python :: meme command discord.py 
Python :: minimum and max value in all columns pandas 
Python :: python suppress exponential notation 
Python :: python write yaml 
Python :: python input. yes or no 
Python :: length ofarray in ptyon 
Python :: how to provide default value when assign i ngvariables python 
Python :: talos get best model 
Python :: Check for duplicate values in dataframe 
Python :: ignore error open file python 
Python :: start the environment 
Python :: how to traverse a linked list in python 
Python :: divide by zero errors when using annotate 
Python :: extract topic to csv file 
Python :: python create environment variable 
Python :: import c# dll in python 
Python :: place a widget in tkinter 
Python :: knn plot the clusters 
Python :: turn of axis 
Python :: how to ask someone for their name in python 
Python :: access element of dataframe python 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =