Python Program to check whether a given number is an Armstrong Number or not using lambda and list

Program

num = int(input("Enter a number:\t"))
a = list(map(int,str(num)))
b = list(map(lambda x : x ** 3, a))
if sum(b) == num:
    print(num, "is an armstrong number")
else:
    print(num, "is not an arsmtrong number")

Output 1

Enter a number:	89
89 is not an arsmtrong number

Output 2

Enter a number:	407
407 is an armstrong number

Tags: