
saxenadivya859
Friday, 2024-08-02
To check if a number is a palindrome, you need to determine if it reads the same forwards and backwards. Here's a step-by-step guide to do this:
12321, convert it to the string "12321"."12321", the reversed string will also be "12321".def is_palindrome(number):
# Convert the number to a string
num_str = str(number)
# Reverse the string
reversed_str = num_str[::-1]
# Check if the original string is equal to the reversed string
return num_str == reversed_str
# Example usage
print(is_palindrome(12321)) # True
print(is_palindrome(12345)) # False