Multi Dimensal Array

Asked by Jeff_Vallis on 2017-10-29

Can U give me a simple example of how to create and use a multi dimensional array
for example
create an array to store 3 sets of values - append values - print values
my test
threeD = []
threeD.append((1, 2, 3))
threeD.append((4, 5, 6))
print len(threeD)
print len(threeD[0])
print threeD[0]

and here is where I fail

print threeD[0,0,0]
print threeD[0] [0] [0]

maybe I am appending them wrong or maybe its the print
have tried lots of permutation

Regards

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
2017-10-30
Last query:
2017-10-30
Last reply:
2017-10-29
Best masuo (masuo-ohara) said : #1

threeD[0,0,0] is wrong how to write subscripts.

And in your case
numbers of data: 2
numbers of element: 3
So threeD[0] [0] [0] is wrong.

threeD = []
threeD.append([1,2,3])
threeD.append([4,5,6])

print "numbers of data:",len(threeD)
print "numbers of element:",len(threeD[0])

for i in range(2):
    print "data:%d" % (i+1)
    for j in range(3):
        print threeD[i][j];

Jeff_Vallis (vallis-pj) said : #2

Perfect thanx