while q:
    entry = q.pop()
if isinstance(entry, list):
    q += entry
count += 1
return count
print(element_count([1, [], 3]))
print(element_count([1, [1, 2, [3, 4]]]))
print(element_count([[[[[[[[1, 2, 3]]]]]]]]))
Count all elements in list of arbitrary nested list without recursion