Reputation: 11
I've made some generic example of my problem.
I have something like this:
n = 2
test = [[[0,0] for j in range(1)] for k in range(n)]
print(test)
And I get the following output:
[[[0, 0]], [[0, 0]]]
But what I want - as output - is something like that:
[[[0, 0]], [[0, 0],[0, 0]]]
And for n = 3, the output must be:
[[[0, 0]], [[0, 0],[0, 0]], [[0,0],[0,0],[0,0]]]
Upvotes: 0
Views: 44
Reputation:
You can do it by specifying the start
argument of range
:
[[[0,0] for _ in range(k)] for k in range(1, n+1)]
Output (for n=3
):
[[[0, 0]], [[0, 0], [0, 0]], [[0, 0], [0, 0], [0, 0]]]
Upvotes: 0