List 3 dimensions reference does not work - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: List 3 dimensions reference does not work (/thread-8618.html) |
List 3 dimensions reference does not work - Mario793 - Feb-28-2018 Hello, I am currently working on a program to plot some data in Python, and I have a little problem with referencing some values from an array of three dimensions. Mi code, part of it, is the following: for i in range(0,numberOfDistances): print(meanHeatFluxValue[0][i][0]) print(meanHeatFluxValue) print("Uno=",meanHeatFluxValue[0][0][0]) print("Dos=",meanHeatFluxValue[0][1][0]) print("Tres=",meanHeatFluxValue[0][2][0]) print("Cuatro=",meanHeatFluxValue[0][3][0]) print("Cinco=",meanHeatFluxValue[0][4][0]) print("Total=",meanHeatFluxValue[0][0:5][0]) print("Total2=",meanHeatFluxValue[0][:][0]) print(peak1MHF[0:5])and the results in console are: I thought print("Total=",meanHeatFluxValue[0][0:5][0]) print("Total2=",meanHeatFluxValue[0][:][0])give me the values of the 5 first elements, the first one, and all the elements, the later, but it seems it is not working or I have misunderstood it. Could somebody give me an answer why it is not working and how to solve it or make it work? PD: I have created a variable to save the values with the following code and with it is working, but I would like to make it work with the original list. for d in range (0,numberOfDistances): peak1MHF.append(meanHeatFluxValue[0][d][0] RE: List 3 dimensions reference does not work - ka06059 - Mar-02-2018 try print("Total=", zip(meanHeatFluxValue[0][0:5])[0]) print("Total2=",meanHeatFluxValue[0]) |