The problem is that the second example you give does not match the first. This is easier to understand if you look at the value of x[np.array([1, 1, 3, 1])] + 1 separately, which numpy computes in both examples.
The value of x[np.array([1, 1, 3, 1])] + 1 is what you expected: array([11, 11, 31, 11]) .
>>> x = np.arange(0, 50, 10) >>> x array([ 0, 10, 20, 30, 40]) >>> x[np.array([1, 1, 3, 1])] + 1 array([11, 11, 31, 11])
In Example 1, you assign this answer to elements 1 and 3 in the original x array. This means that a new value of 11 is assigned to element 1 three times.
However, in Example 2, you replace the original array x with the new array([11, 11, 31, 11]) .
This is the correct equivalent code for your first example and gives the same result.
>>> x = np.arange(0, 50, 10) >>> x array([ 0, 10, 20, 30, 40]) >>> x[np.array([1, 1, 3, 1])] = x[np.array([1, 1, 3, 1])] + 1 >>> x array([ 0, 11, 20, 31, 40])