Jul-11-2019, 01:57 PM
If I correctly understand the objective then no iteration is needed.
You just want to replace first element in every row in matrix with value which in reference list. As indexes of rows in matrixes and elements in reference list are the same one can just:
You just want to replace first element in every row in matrix with value which in reference list. As indexes of rows in matrixes and elements in reference list are the same one can just:
>>> lst = [[2,13,22,40],[8,13,22,40],[24,13,22,40]] >>> reference = [5, 10, 30] >>> for i, v in enumerate(reference): ... lst[i][0] = v ... >>> lst [[5, 13, 22, 40], [10, 13, 22, 40], [30, 13, 22, 40]]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.