Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First "End Zero" solution in Clear category for End Zeros by olgag
def end_zeros(num: int) -> int:
# more pythonic solution using rstrip
return len(str(num)) - len(str(num).rstrip('0'))
def end_zeros1(num: int) -> int:
# solution using string reverse and break
count = 0
for itm in str(num)[::-1]:
if itm == "0":
count+=1
else:
break
return count
Feb. 1, 2021
Comments: