n=int(input("Enter a Number: "))
x=0
y=0
z=0while(n>0):x=n%10y=x**3z=z+yn=n//10print (z) #The z here is the same value which I enter, yet it doesn't work.
#If I enter 407 as n, z becomes (4^3)+(0^3)+(7^3) which is 407if (z==n): #But even when 407==407, it just wont print the bottom statementprint ("The number is Armstrong")
else:print ("The number isn't Armstrong")#it prints that it isn't an Armstrong number
After the while
loop, n
already became 4//10
which is 0
, so it'll never equal z
which is 407.
You will want to keep a copy of the original input for comparison.
As a general advice, use a debugger or at least print()
your objects to see where the assignments went wrong.