0

What's is the error in this program amstrong number

a= int(input('enter the number :')) total=0 temp=a while a>0 : b=a%10 total= total+b**3 temp=temp//10 print('total value is %d',total) if a==total : print('It is an amstong number') else : print(It is not an amstrong number )

18th Mar 2020, 3:00 PM
Ragul P
Ragul P - avatar
3 Respostas
0
Output screen shows indentation error
18th Mar 2020, 3:03 PM
Ragul P
Ragul P - avatar
+ 9
It's because the indentation is different for all lines inside the loop. Make indentation same (4 spaces) for all lines inside loops and control statements.
18th Mar 2020, 3:11 PM
Nova
Nova - avatar
+ 7
Change the condition to while temp>0 as you are reducing the value of temp inside the loop. In your case, the loop goes on forever I think.
18th Mar 2020, 3:02 PM
Nova
Nova - avatar