Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 475

Python: Why randint on a matrix keeps giving me the same rows [duplicate]

$
0
0

I'm using Python 3 and with this code:

import randommat = [[0]*5]*5for i in range (0,5) :    for j in range (0,5)  :        mat[i][j] = random.randint(10,50)print (mat)

I'm getting results like this:

[[26, 10, 28, 21, 15], [26, 10, 28, 21, 15], [26, 10, 28, 21, 15], [26, 10, 28, 21, 15], [26, 10, 28, 21, 15]]

The rows are equal each other, but the loop seems to be alright.

What is the problem?


Viewing all articles
Browse latest Browse all 475

Trending Articles