I'd like to list the number of 3*3 cases using Python.

Asked 2 years ago, Updated 2 years ago, 24 views

I'm a programming beginner who just started studying with Python.

a1, a2, a3

b1, b2, b3

c1, c2, c3

3 * 3 * 3 I'd like to list a total of 27 cases

Is there a master who can make an example?

python probability

2022-09-21 19:15

1 Answers

mylist = [[1,2,3],[4,5,6],[7,8,9]]

mylist[0][0]
mylist[0][1]
mylist[0][2]

mylist[1][0]
mylist[1][1]
mylist[1][2]

mylist[2][0]
mylist[2][1]
mylist[2][2]

You mean this, right?

mylist = [[1,2,3],[4,5,6],[7,8,9]]

for i in range(3):
    for j in range(3):
       print(mylist[i][j])

Right?

mylist = []
for i in range(3):
    for j in range(3):
            for k in range(3):
                mylist[i][j][k] = i+j+k
                print(mylist[i][j][k])

3*3*3*3 is right, right?


2022-09-21 19:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.