title: Numpy: Change values in numpy array by indexes and condition
body: <p>I am new in numpy, and I am having troubles with simple managment of numpy arrays.</p>
  
  <p>I am doing a task in which it said that loops has to be avoid as much as possible, and I need to edit the values of an array through another array of indexes.</p>
  
  <pre><code>indexes # [3, 16]
  y # [0. 1. 1. 1. 0. 1. 0. 0. 0. 0. 1. 1. 1. 0. 1. 0. 0. 0. 1. 1.]
  y[indexes] = 2 # [0. 1. 1. 2. 0. 1. 0. 0. 0. 0. 1. 1. 1. 0. 1. 0. 2. 0. 1. 1.]
  </code></pre>
  
  <p>But I don't need change the value simply by 2. I need make a conditional change. This what I have got, but I would need something like</p>
  
  <pre><code>y[indexes] = 0 if y[indexes] == 1 else 0 
  &gt;&gt;&gt; [0. 1. 1. 0. 0. 1. 0. 0. 0. 0. 1. 1. 1. 0. 1. 0. 1. 0. 1. 1.]
  </code></pre>
  
  <p>And the line above should be the results.</p>
  
  <p>This is the loop way answer, but I need a numpy way if exists:</p>
  
  <pre><code>for index in indexes:
      y[index] = 1 if y[index] == 0 else 0
  </code></pre>
  
  <p>Thanks in advance.</p>