Python Colon operator

python

Solution

This is called list slicing, you already link to the proper part of the documentation in your question. If you find documentation confusing, there is a video tutorial for that:

http://www.youtube.com/watch?v=iD6a0G8MnjA

Problem

I am trying to port some Python code and I am a little lost on small issue which I would appreciate some advice. I understand the `in` operator but I am a little unclear on what the `:` operator does in this example. ``` if foo in bar[i][:2]: # do something ``` In http://docs.python.org/tutorial/introduction.html#strings it states that the `:` 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

Original source

Related problems