Python Program to Print Happy Numbers from 1 to 100

Write a Python program to print Happy numbers from 1 to 100 or within a range. This Python example accepts the minimum and maximum values and displays the Happy numbers within that range.

import math
def digitsSquareSum(Number):
    Sum = rem = 0
    while Number > 0:
        rem = Number % 10
        Sum = Sum + math.pow(rem, 2)
        Number = Number // 10
    return Sum


minHpy = int(input("Enter the Minimum Happy Number = "))
maxHpy = int(input("Enter the Maximum Happy Number = "))

print("\nThe List of Happy Numbers from {0} and {1}".format(minHpy, maxHpy)) 
for i in range(minHpy, maxHpy + 1):
    Temp = i

    while Temp != 1 and Temp != 4:
        Temp = digitsSquareSum(Temp)

    if Temp == 1:
        print(i, end  = '  ')
Python Program to Print Happy Numbers from 1 to 100