as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
create a function to to check if a given number is an armstrong number or not.
user
"""
check if a given number is an armstrong number or not
"""

def isarmstrongnumber(num): 
    # calculate the length of num 
    n = len(str(num)) 
  
    # initialize sum 
    sum = 0
  
    # find a sum of nth power of    
    # individual digits
    temp = num 
    while temp > 0: 
        digit = temp % 10
        sum += digit ** n 
        temp //= 10
  
    # return true if num is equal to the sum 
    # of nth power of its digits
    if num == sum: 
        return true
    else: 
        return false

if __name__ == '__main__':
    print(isarmstrongnumber(153))
assistant