title: What does x[x < 2] = 0 mean in Python?
body: <p>I came across some code with a line similar to</p>
  
  <pre><code>x[x&lt;2]=0
  </code></pre>
  
  <p>Playing around with variations, I am still stuck on what this syntax does.</p>
  
  <p>Examples:</p>
  
  <pre><code>&gt;&gt;&gt; x = [1,2,3,4,5]
  &gt;&gt;&gt; x[x&lt;2]
  1
  &gt;&gt;&gt; x[x&lt;3]
  1
  &gt;&gt;&gt; x[x&gt;2]
  2
  &gt;&gt;&gt; x[x&lt;2]=0
  &gt;&gt;&gt; x
  [0, 2, 3, 4, 5]
  </code></pre>