given some Positions of values in a nested List, I'm interested in retrieving this value. e.g.
indices1 = [0,0] # "A"
indices2 = [0,1, 1] # "D"
lst = [['A', ['B', 'D']], 'C']
I now wan't to create a "getter" and "setter"
def get(interesting_list, indices: List[int]):
# I don't know this part, so multiple tries
return interesting_list[indices]
def set(interesting_list, indices: List[int], new_val):
interesting_list[indices] = new_val
in the end I want to call
get(lst, indices1)
I thought about using sth like
indices1 = [0,0] # "A"
indices2 = [0,1, 1] # "D"
lst = [['A', ['B', 'D']], 'C']
I now wan't to create a "getter" and "setter"
def get(interesting_list, indices: List[int]):
# I don't know this part, so multiple tries
return interesting_list[indices]
def set(interesting_list, indices: List[int], new_val):
interesting_list[indices] = new_val
in the end I want to call
get(lst, indices1)
I thought about using sth like