代码:
num=input("enter to check for armstrong num : ")
num1=num
sum=0
while(num!=0):
sum+=(num%10)**3
num/=10
if(sum==num1):
print(sum," is an armstrong number ")
else:
print("go find another number")
输出显示:
enter to check for armstrong num : 123
Traceback (most recent call last):
File "armstrong.py", line 5, in <module>
sum+=(num%10)**3
TypeError: not all arguments converted during string formatting