Python Palindrome Number with Example

 

Palindrome Program in Python

In the palindrome program, we learn whether the given string is Palindrome or not.

Palindrome number is such number which if you write opposite then it will be the same as previous number. Let see one simple example of a palindrome number i.e. 121 if you write from the last digit to the first digit then still it will be the same. There will not be any changes in the number. This can be also performed in String. 

There are different example of plindrome i.e. ‘dad’, ‘mom’, ‘aibohphobia’, etc.

Palindrome Number Source Code

def palindrome(name):

rev=name[::-1]

if name==rev:

return "palindrome"

return "not palindrome"

name=input("enter any string: ")

print(palindrome(name))

Output:

Input as: 12121212121

C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py
enter any string: 12121212121
palindrome

Process finished with exit code 0

Input as: dad

C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py
enter any string: dad
palindrome

Process finished with exit code 0

Input as: aibohphobia

C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py
enter any string: aibohphobia
palindrome

Process finished with exit code 0

Input as: Book

C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py
enter any string: Book
not palindrome

Process finished with exit code 0
Palindrome Program in Python

Recommended Post:

Get Salesforce Answers

Pramod Kumar Yadav is from Janakpur Dham, Nepal. He was born on December 23, 1994, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India. Pramod has worked as the owner of RC Educational Foundation Pvt Ltd, a teacher, and an Educational Consultant, and is currently working as an Engineer and Digital Marketer.



1 thought on “Python Palindrome Number with Example”

Leave a Comment