Convert list of positions [4, 1, 2] of arbitrary length to an index for a nested list
Assuming this list nestedList = ["a", "b", [1, 2, 3], "c",[4, 5, 6, [100, 200, 300]], "d"] I have a function that returns a position list for a nested list of arbitrary depth. Examples : [2, 1] -> "2" [5] -> "d" [4, 3, 2] -> "300" As you can see it is not clear in the beginning how many levels of nesting there are. Additional Problem For list modifications I want to use the [:] or [4:] or [0:1] notations. For a human its very easy to do: simply add as many index position as you need to. nestedList[2][1] nestedList[5] nestedList[4][3][2] nestedList[4][1:] = NewItem + nestedList[4][1:] #insert