title: Flip the entries in a list without looping
body: <p>In Python, I have a list of zeros and ones (could be very long), e.g., </p>
  
  <pre><code>L = [0,1,0,1,1,0,1,0,0,1]
  </code></pre>
  
  <p>I want to flip every entry in the list without use loop, e.g., make 0 to 1 and make 1 to 0.</p>
  
  <p>My idea is the following: this L can be viewed as a binary representation of a real number. So I wish to make L become <code>0101101001</code>, then I think there is some bit operation could directly do the flip job. And eventually, I need to make the flipped term back to list, i.e., <code>1010010110</code> to <code>[1,0,1,0,0,1,0,1,1,0]</code></p>
  
  <p>Is there a way to implement this idea in Python (without using <code>numpy</code>)? Will this method significantly faster than loop? Will this method be the fastest way to achieve this goal? </p>
  
  <p>It is an interview question. I couldn't answer on site. I am not allow to use library like <code>numpy</code>.</p>