I want to extract all the zeros from a number and find the length of the number of zeros using Python recursion. I've tried the following code but it gives me an error. I can do that using for loop but I want to know how python recursion does this. For this code output should be 3.
def zeros(n):
x = list(str(n))
if x == []:
return []
else:
head = x[0]
tail = "0"
return len([head]) + zeros(tail)
print(zeros(10010))
RecursionError: maximum recursion depth exceeded while calling a Python object