I usually do my incrementation this way:
n=0
n=n+1 # and never do n+=1
Now there is code that I am trying to comprehend and I'm struggling to understand it.
sum=0
temp = num
while temp > 0:
digit = temp % 10
# below is the line I do not understand
sum += digit ** power # what is happening here?. with power= len(str(num))
temp //= 10
if num == sum:
print num
This snippet is a piece to list the armstrong numbers.
sum += digit ** poweris equivalent tosum = sum + digit ** power.numis not defined, please explain whatnumis.n ** xmeans. Thus, an MCVe isn't necessary.