I would like to create the following array of arrays:
[[1, 1, 1],
[1, 2, 4],
[1, 3, 9],
[1, 4, 16],
[1, 5, 25],
[1, 6, 36],
[1, 7, 49],
[1, 8, 64],
[1, 9, 81],
[1, 10, 100]]
And this is my code:
rows = 10
cols = 3
arr = []
x = [1, 1, 1]
for i in range(rows) :
for j in range(cols) :
x[j] = (i + 1) ** j
arr.append(x)
print(arr)
The output I'm getting is:
[[1, 10, 100],
[1, 10, 100],
[1, 10, 100],
[1, 10, 100],
[1, 10, 100],
[1, 10, 100],
[1, 10, 100],
[1, 10, 100],
[1, 10, 100],
[1, 10, 100]]
It seems like there's an error somewhere, but I cant see it, any feedback would be appreciated!