• Count-Trailing-Zeros(x) --- Can I use Log(x) to see if X is equal to (

    From Hen Hanna@21:1/5 to All on Sun Sep 18 08:49:37 2022
    Count how many zeros are at the end of your int:

    def end_zeros(num):
    s = str(num)
    return len(s) - len(s.rstrip("0"))


    print(end_zeros(10)) # == 1
    print(end_zeros(101)) # == 0
    print(end_zeros(245)) # == 0
    print(end_zeros(100100)) # == 2


    ---------------- Writing a loop (using % and // ) feels like [reinventing the wheel] and seems intrinsically wrong.


    i like this code (above) because it's not reinventing the wheel --- the Python implementor has already done the loop (using % and // ), so i'm just using that efficient tool (routine).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)