How do I count the trailing zeros in integer?
May be you can try doing this. This may be easier than counting each trailing '0's
def trailing_zeros(longint):
manipulandum = str(longint)
return len(manipulandum)-len(manipulandum.rstrip('0'))
For strings, it is probably the easiest to use rstrip()
:
In [2]: s = '23989800000'
In [3]: len(s) - len(s.rstrip('0'))
Out[3]: 5