This question already has answers here:
How to define a two-dimensional array?
(30 answers)
Closed 3 years ago.
Matrices can be represented as a list of lists in Python.
For example a 5 x 5 matrix with values 0 to 4 in each row can be written as:
matrix = [[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4]]
How to recreate this matrix by using nested listed comprehensions?
Here is my code:
num = [[num1,num2,num3,num4,num5] for num1 in range(5) for num2 in range(5)for num3 in range(5)for num4 in range(5)for num5 in range(5)]
And it produce the following output:
[[0, 0, 0, 0, 0],
[0, 0, 0, 0, 1],
[0, 0, 0, 0, 2],
[0, 0, 0, 0, 3],
[0, 0, 0, 0, 4],
[0, 0, 0, 1, 0],
[0, 0, 0, 1, 1],
[0, 0, 0, 1, 2],
[0, 0, 0, 1, 3],
[0, 0, 0, 1, 4],
[0, 0, 0, 2, 0],
[0, 0, 0, 2, 1],
[0, 0, 0, 2, 2],
[0, 0, 0, 2, 3],
[0, 0, 0, 2, 4],
[0, 0, 0, 3, 0],
[0, 0, 0, 3, 1],
[0, 0, 0, 3, 2],
[0, 0, 0, 3, 3],
[0, 0, 0, 3, 4],
[0, 0, 0, 4, 0],
[0, 0, 0, 4, 1],
[0, 0, 0, 4, 2],
[0, 0, 0, 4, 3],
[0, 0, 0, 4, 4],
[0, 0, 1, 0, 0],
[0, 0, 1, 0, 1],
[0, 0, 1, 0, 2],
[0, 0, 1, 0, 3],
[0, 0, 1, 0, 4],
[0, 0, 1, 1, 0],
[0, 0, 1, 1, 1],
[0, 0, 1, 1, 2],
[0, 0, 1, 1, 3],
[0, 0, 1, 1, 4],
[0, 0, 1, 2, 0],
[0, 0, 1, 2, 1],
[0, 0, 1, 2, 2],
[0, 0, 1, 2, 3],
[0, 0, 1, 2, 4],
[0, 0, 1, 3, 0],
[0, 0, 1, 3, 1],
[0, 0, 1, 3, 2],
[0, 0, 1, 3, 3],
[0, 0, 1, 3, 4],
[0, 0, 1, 4, 0],
[0, 0, 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2, 3, 2],
[1, 2, 2, 3, 3],
[1, 2, 2, 3, 4],
[1, 2, 2, 4, 0],
[1, 2, 2, 4, 1],
[1, 2, 2, 4, 2],
[1, 2, 2, 4, 3],
[1, 2, 2, 4, 4],
[1, 2, 3, 0, 0],
[1, 2, 3, 0, 1],
[1, 2, 3, 0, 2],
[1, 2, 3, 0, 3],
[1, 2, 3, 0, 4],
[1, 2, 3, 1, 0],
[1, 2, 3, 1, 1],
[1, 2, 3, 1, 2],
[1, 2, 3, 1, 3],
[1, 2, 3, 1, 4],
[1, 2, 3, 2, 0],
[1, 2, 3, 2, 1],
[1, 2, 3, 2, 2],
[1, 2, 3, 2, 3],
[1, 2, 3, 2, 4],
[1, 2, 3, 3, 0],
[1, 2, 3, 3, 1],
[1, 2, 3, 3, 2],
[1, 2, 3, 3, 3],
[1, 2, 3, 3, 4],
[1, 2, 3, 4, 0],
[1, 2, 3, 4, 1],
[1, 2, 3, 4, 2],
[1, 2, 3, 4, 3],
[1, 2, 3, 4, 4],
[1, 2, 4, 0, 0],
[1, 2, 4, 0, 1],
[1, 2, 4, 0, 2],
[1, 2, 4, 0, 3],
[1, 2, 4, 0, 4],
[1, 2, 4, 1, 0],
[1, 2, 4, 1, 1],
[1, 2, 4, 1, 2],
[1, 2, 4, 1, 3],
[1, 2, 4, 1, 4],
[1, 2, 4, 2, 0],
[1, 2, 4, 2, 1],
[1, 2, 4, 2, 2],
[1, 2, 4, 2, 3],
[1, 2, 4, 2, 4],
[1, 2, 4, 3, 0],
[1, 2, 4, 3, 1],
[1, 2, 4, 3, 2],
[1, 2, 4, 3, 3],
[1, 2, 4, 3, 4],
[1, 2, 4, 4, 0],
[1, 2, 4, 4, 1],
[1, 2, 4, 4, 2],
[1, 2, 4, 4, 3],
[1, 2, 4, 4, 4]]
Please someone help me to solve this.
Try this,
>>> [[j for j in range(5)] for i in range(5)]
Output:
[[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4]]