Im trying to make a function which finds a value from a list (xs) using another list (index_list) as an index path.
My function should work like this:
xs = [[[1, 2], 3], [4, 5, [6, 7]], 8, [9, 10, 11]]
>>> recursive_index(xs, [1, 2, 0])
6
So far I have:
def recursive_index(xs: List, index_path):
if not index_path:
return 0
return recursive_index(xs, index_path[1:])
This however just returns 0 for everything, but I don't know what else the base case should be.