Python Colon Operator

I am trying to port some Python code and I lost a little bit of a problem and I would appreciate some advice.

I understand the operator in, but I do not understand a bit 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 it is a string. However, when used with a list like this, what will happen? So that means only the first 2 characters of the string in th

+3
source share
2 answers

, - , , . , , , .

+1

All Articles