Files
cybr108/lab-05/exercise-16.py
T
2026-10-12 17:04:04 -04:00

23 lines
736 B
Python

"""
Write a program to check if a given number is a palindrome. A palindrome number is a number that remains the same
when its digits are reversed (e.g., 121, 343)
"""
#Set variables for input number, result, and storing original input value so it doesn't get overwritten
number = 121
original = number
result = 0
# While loop that strips last digit of number
while number > 0:
digit = number % 10
# Adds stripped digit to result var and multiplies by 10
result = result * 10 + digit
# Resets number var to number without stripped digit
number = number // 10
#Checks if result var matches original var and prints confirmation
if result == original:
print("Palindrome")
else:
print("Not a palindrome")