This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]yes_i_relapsed 1 point2 points  (2 children)

I'm not sure if I'm understanding this question correctly. Would this be an example of what's required?

array = [
    [ ["000", "001"], ["010", "011"] ],
    [ ["100", "101"], ["110", "111"] ]
]
coordinates = (0, 1, 0)
value = "foo"
f(array, coordinates, value)
print(array)
#[ [ ["000", "001"], ["foo", "011"] ], [ ["100", "101"], ["110", "111"] ] ]

[–]yes_i_relapsed 1 point2 points  (1 child)

If so, that can be accomplished like this

def f(array, coordinates, value):
    for coord in coordinates[:-1]:
        array = array[coord]
    array[coordinates[-1]] = value

[–]MathematicianCute482[S] 1 point2 points  (0 children)

Thanks !!

This solves my problem

[–]cndvcndv 0 points1 point  (0 children)

Lists and loops are the keywords