Palindrome Number in Python Without using String Functions

We will develop a palindrome number in python without using string functions. It will check if the given number is a palindrome number or not. If the Reverse of a number is equal to the same number then the number is called a palindrome number.

Example of palindrome number:-
12021 = 12021 So, 12021 is a palindrome number.
32105 != 50123 So, 32105 is not a palindrome number.

Palindrome Program in Python Without using String Functions

We will take an integer number as a string while declaring the variables. Check if the number is equal to the reverse number or not using the if-else statement. Finally, the result will be displayed on the screen.

Program Description:- Write a Python program to check if the number is a palindrome or not without using string functions

# Palindrome number in python without using string functions

# take inputs
num = '66'
# check number is palindrome or not
if(num == num[::-1]):
   print(num,'is a Palindrome')
else:
   print(num,'is not a Palindrome')

Output:-

66 is a Palindrome

Palindrome Number in Python Without using String Functions

In the previous program, inputs are hardcoded in the program but in this program, input will be provided by the user.

Program Description:- Write a program to check if the given number is a palindrome or not in Python without using string functions

# Palindrome number in python without using string functions

# take inputs
num = input('Enter the number: ')

# check number is palindrome or not
if(num == num[::-1]):
   print(num,'is a Palindrome')
else:
   print(num,'is not a Palindrome')

Output for the input values test-case-1:-

Enter the number: 393
393 is a Palindrome

Output for the input values test-case-2:-

Enter the number: 9564
9564 is not a Palindrome

Output for the input values test-case-3:-

Enter the number: 1551
1551 is a Palindrome

Leave a Comment

Your email address will not be published. Required fields are marked *