back soft

مطالب مرتبط با «python list of arrays» در back soft | نویسنده: استخدام کار

Python list of lists filled with duplicate rows after writing each entry

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 agowrkyle Let's block ads! بخوانید...

ادامه مطلب

برچسب‌های مرتبط

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