[Solved] Palindrome Checker for numbers


The easiest way to check if a number is a palindrom would probably to treat it as a string, flip it, and check if the flipped string is equal to the original. From there on, it’s just a loop that counts how many of these you’ve encounteres:

begin = int(input('Enter begin: '))
end = int(input('Enter end: '))

palindromes = 0
#Add your code here. You will want to start with a "for x in range" style loop.
for x in range(begin, end):
    if str(x) == str(x)[::-1]:
        palindromes += 1

print('There are', palindromes, 'palindrome(s) between', begin, 'and', end)

6

solved Palindrome Checker for numbers