0
How to write an Armstrong number program using python in 2 lines?
4 Respostas
+ 1
a=input()
print("Armstrong") if (sum(int(i)**3 for i in a))==int(a) else print("not an armstrong number")
You can do something like this using ternary operator ,list comprehension for evaluating cube of each digit and then applying sum function
,ignore my previous answer ,that's wasn't evaluating as expected , lambda is an anonymous function which is created when the program runs and destroyed after that
0
Ok tq
0
May I know what is the use of lambda there....
0
Ok tq