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!...
ادامه مطلبVote count: 0 I have two lists that I want to combine for csv output. alist = ['a', 'b', 'c'] blist = ['d', 'e', 'f'] However, I want the output for the csv to format like this: clist = ['a', 'b', 'c', 'd' 'e' 'f'] such that the last entry extended of the list contains the list of "blist", but will not be comma separated. Unfortunately, what I have been trying instead gives me: clist = ['a', 'b', 'c', 'def'] asked 1 min agoArca Let's block ads!...
ادامه مطلب