Nov-25-2016, 11:38 AM
Hello,
currently I have an issue with initializing a four dimensional array with different lengths in every dimension. I use python 2.7.12 on Windows 7. The following example gives me an error on the array dimension:
Thank you all in advance
currently I have an issue with initializing a four dimensional array with different lengths in every dimension. I use python 2.7.12 on Windows 7. The following example gives me an error on the array dimension:
a=3 b=4 c=5 d=1 test=[[[[1 for w in range(a)] for x in range(b)] for y in range(c)] for z in range(d)] for w in range(a): for x in range(b): for y in range(c): for z in range(d): print(test[w][x][y][z])
Error:IndexError: list index out of range
I do not understand this error message since i call the the array "test" within the exact same range I initalizied it. I have already treid fixing this by adding +1 to the range of every dimension of the array test but the error still occurs. Any kind of comment or help on this issue is much appreciated!Thank you all in advance