Write a function that checks if a number is an Armstrong number (sum of digits of the number = the number)


Topic: Write a function that checks if a number is an Armstrong number (sum of digits of the number = the number)

Solution

from itertools import chain
def check_armstrong(n):
    sum_of_digits = sum(map(lambda x: int(x) ** 3, chain(str(n))))
    if sum_of_digits == n:
        return True
    else:
        return False



List all Python Programs