在阿姆斯特朗号码程序中的TypeError

时间:2016-06-08 15:01:02

标签: python python-3.x

代码:

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

0 个答案:

没有答案