Skip to content Skip to sidebar Skip to footer

Row Exchange In Numpy

In Python I can exchange 2 variables by mean of multiple affectation; it works also with lists: l1,l2=[1,2,3],[4,5,6] l1,l2=l2,l1 print(l1,l2) >>> [4, 5, 6] [1, 2, 3] But

Solution 1:

This works the way you intend it to:

a3[[0,1]] = a3[[1,0]]

The two separate assignments in the tuple assignment are not buffered with respect to eachother; one happens after the other, leading the overwriting your observe

Post a Comment for "Row Exchange In Numpy"