I was trying to write a function that takes a list and and an element as input and returns it's deepness. If the element is not found, returns -1
def find_e(l, e):
for i in l:
if isinstance(i, list):
return find_e(i, e) + 1
if i == e:
return 1
else:
return -1
For inputs
[[1, 9], 0, [[[["a"]]]]], "a"
[[1, 9], 0, [[[["a"]]]]], "b"
It should return 5 and -1, but this clearly doesn't work.