I have a multidimensional array but I won't know the number of dimensions or the size of each dimension. How can I generalize the code such that I can access each element of the array individually?
import numpy as np
import random
myRand = np.random.rand(5, 6, 7)
#print (myRand.shape[0])
# This works great if I already know that myRand has 3 dimensions. What if I don't know that?
mySum = 0.0
for i in range(myRand.shape[0]):
for j in range(myRand.shape[1]):
for k in range(myRand.shape[2]):
# Do something with myRand[i,j,k]