Python Program to Print Palindrome Numbers

Python Program to Print Palindrome Numbers

  • Write a Python Program to print Palindrome numbers from 1 to 10000 or 1 to n or minimum to maximum with an example.
  • First, we used For Loop to iterate a loop between 1 and maximum value. within the for loop
  • We used While Loop to reverse the given number
  • The if statement checks whether the given number is Palindrome Number or Not, for this, it compares the original value with the reverse number.

Source Code:

# Python Program to print Palindrome numbers
maximum = int(input(" Please Enter the Maximum Value : "))

print("Palindrome Numbers between 1 and %d are : " %maximum)
for num in range(1, maximum + 1):
    temp = num
    reverse = 0
   
    while(temp > 0):
        Reminder = temp % 10
        reverse = (reverse * 10) + Reminder
        temp = temp //10

    if(num == reverse):
        print("%d " %num, end = '  ')

 

 

 

Comments