title: Python Colon operator
body: <p>I am trying to port some Python code and I am a little lost on small issue which I would appreciate some advice.</p>
  
  <p>I understand the <code>in</code> operator but I am a little unclear on what the <code>:</code> operator does in this example.</p>
  
  <pre><code>if foo in bar[i][:2]:
      # do something
  </code></pre>
  
  <p>In <a href="http://docs.python.org/tutorial/introduction.html#strings" rel="nofollow">http://docs.python.org/tutorial/introduction.html#strings</a> it states that the <code>:</code> operator makes the first two characters only if this is a string. However when used with a list like this is that what will happen as well? So does this just mean the first 2 characters of the string in th</p>