Def bal_sheet () :
W=[]
For I in range (100) :
For j in range (100) :
For k in range (8) :
W [I] [j] [k]. Append (0)
How to initialize, please? List data is more, it is 3 d, it is not possible manual list
CodePudding user response:
Recommend to use numpy generated 3 d tensor, initialized, when transformed into 3 d array,CodePudding user response:
[[[w=0 for I in range (3)] for j in range (3)] for _ in range (3)]Print (w)
Is this mean? Can try to adjust 3 to set the number of layers
CodePudding user response:
Can be found that the following two is initialized, the first in circulation in the body is modified, but out of the loop after reduction for 0.W=[85] [2] [0] * * * 8
The second method, cycle, after the modification of value out of the loop can be saved,
[[[w=0 for I in range (3)] for j in range (85)] for _ in range (8)]
Strange, please explain