Program to print all palindromes in a given range | A function to check if n is palindrome ; Find reverse of n ; If n and rev are same , then n is palindrome ; prints palindrome between min and max ; Driver Code
def isPalindrome ( n : int ) -> bool : NEW_LINE INDENT rev = 0 NEW_LINE i = n NEW_LINE while i > 0 : NEW_LINE INDENT rev = rev * 10 + i % 10 NEW_LINE i //= 10 NEW_LINE DEDENT return ( n == rev ) NEW_LINE DEDENT def countPal ( minn : int , maxx : int ) -> None : NEW_LINE INDENT for i in range ( minn , maxx + 1 ) : NEW_LINE INDENT if isPalindrome ( i ) : NEW_LINE INDENT print ( i , end = " ▁ " ) NEW_LINE DEDENT DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT countPal ( 100 , 2000 ) NEW_LINE DEDENT