• End Zeros unproperly Checking

 

End Zeros "Extra" Checking Is Not Working

(Or at least I guess so)

Here's my code, it works properly, calculating the n° of zeros at the end of every number in binary. The 'Extra' check is executed with 3456 as input. My code output is 7 and is the correct n° of zeros.

(See the attached screenshot.)

def end_zeros(num: int) -> int:
print(num)
b=str(bin(num))
n=0
for i in range(len(b)-1,0,-1):
    if b[i]=='1':
        return n
    else:
        if b[i]== '0':
            n=n+1
return n

if name == 'main': print("Example:") print(end_zeros(100100))

# These "asserts" are used for self-checking and not for an auto-testing
assert end_zeros(0) == 1
assert end_zeros(1) == 0
assert end_zeros(10) == 1
assert end_zeros(101) == 0
assert end_zeros(245) == 0
assert end_zeros(100100) == 2
print("Coding complete? Click 'Check' to earn cool rewards!")