python - Why does my code return 1 when the given number has more zeroes? -


if have method can me appreciate help, tried best write code calculates number of zeroes in given number.

here's code tried:

def zrc(n):      count=0     while n%10==0 , n!=0:         n=n%10         count=count+1     return count      print(zrc(2500)) 

it gives 1 output of code, while must print 2, numbers 36, gives 0 output, problem? know there must problem while...

if n%10 zero, n 0 in next step, condition fulfilled after first loop. want use // instead of %:

def zrc(n):     count = 0     while n%10 == 0 , n != 0:         n //= 10         count += 1     return count 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -