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

Hi, I’m Pramod Kumar Yadav & a computer science Engineer with 3years of experience in Digital marketing. I’m self-motivated and love to do SEO.




Best PYthon Course

Get More trending Courses

1 thought on “Python Palindrome Number with Example”

Leave a Reply

%d bloggers like this: