title: Create an array according to index in another array in Python
body: <p>I have an array like this:</p>
  
  <pre><code>X= [[1,2,3],
      [3,2,1],
      [2,1,3]]
  </code></pre>
  
  <p>Now I want to create another array Y. The elements in Y should take value 1 at positions where elements in X equal 2, otherwise they should take value 0. In this example, Y should equal to</p>
  
  <pre><code>Y=[[0,1,0],
     [0,1,0],
     [1,0,0]]
  </code></pre>