Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_palindrome(n):
- original = n
- reverse = 0
- while n > 0:
- reverse = reverse * 10 + n % 10
- n //= 10
- return original == reverse
- num = int(input("Enter a number: "))
- if is_palindrome(num):
- print(num, "is a palindrome.")
- else:
- print(num, "is not a palindrome.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement