خرید بک لینک

Vote count: 0

I am iterating over each entry of a list of lists and filling it with some unique number but the final list of lists contains identical rows. Here's a MWE:

x = [1,2,3,4]
y = [3,6,9,12]

Here I set up a list of lists filled with zeros.

m = [[0]*len(x)]*len(y)

And I print it to make sure it looks right.

[print(i) for i in m]

Now I iterate through each row and again through each item in the row and put the result of some calculation in each spot.

for i,ii in enumerate(y):
    for j,jj in enumerate(x):
        m[i][j] = ii*jj

But when I look at the final matrix it is just filled with repeated rows. Any help?

[print(i) for i in m]

asked 1 min ago

برچسب: ,python list of lists,python list of dictionaries,python list of tuples,python list of strings,python list of objects,python list of zeros,python list of files in directory,python list of functions,python list of numbers,python list of arrays,, نویسنده: استخدام کار تاريخ: يکشنبه 17 مرداد 1395 ساعت: 14:10

صفحه بندی