Hello ladies and gentlmen,
Could you please help me to pass the end zeros mission in elementary section?
I use following code tested with success localy, but checkio doesn't let me go further:
#
def end_zeros(num: int) -> int:
offset = -1
result = 0
while int(repr(num)[offset]) == 0:
offset = offset-1
result += 1
return result
#
I receive following error:
IndexError: string index out of range
end_zeros, 4
<module>, 12
I've tested following code locally and the result was fine. I just added two lines: input on the beginning and print on the end to see the outcome.
num = int(input("Number to be checked: "))
def end_zeros(num: int) -> int:
offset = -1
result = 0
while int(repr(num)[offset]) == 0:
offset = offset-1
result += 1
return result
print (end_zeros(num))
Please help me to understand what is wrong.
Thanks in advance for your help!
Created at: April 29, 2020, 7:01 p.m.; Updated at: April 29, 2020, 8:58 p.m.