Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13891

Python matrix input not working this way?

$
0
0

I have tried several ways that are working. But, this one is not.Please help me understand why ?

row, col = 2, 3mat1 = [[None]*col]*rowprint(mat1)for i in range(0, row):    for j in range(0, col):        mat1[i][j] = int(input())print(mat1)

Input:

123456

Expected:

[[1,2,3], [4,5,6]]

Getting:

[[4,5,6], [4,5,6]]

Viewing all articles
Browse latest Browse all 13891

Trending Articles