0

Given two multi-dimensional arrays, the first multi-dimensional array containing the values and the second multi-dimensional array containing the objects. How to set attributes of all the objects in the second array such that the attributes are the values from the first multi-dimensional array?

md_array_1 = [[[14, 15, 18], [24, 21]], [[12, 13, 21], [15, 14]]]
md_array_2 = [[[obj_1, obj_2, obj_3], [obj_4, obj_5]], [[obj_6, obj_7, obj_8], [obj_9, obj_10]]]

obj_1.value = 14
obj_2.value = 15
obj_3.value = 18

1 Answer 1

1
for sublist1, sublist2 in zip(md_array_1, md_array_2):
   for sublist_1, sublist_2 in zip(sublist1, sublist2):
       for val, obj in zip(sublist_1, sublist_2):
           obj.value = val
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.