Swap two values in a numpy array. November 30, 2023 by Tarik I see you’re using numpy arrays. In that case, you can also do this: input_seq[[ix1, ix2]] = input_seq[[ix2, ix1]]