Censor


#1

What's the difference between

a[1]

and

a[1:]

? I don't really get it.


#2

Let's suppose you have a list:

a=[1, 2, 3, 4]

a[1] means item at index 1.

print a[1] >> 2

a[1:] means every item starting at index 1 (like range(1,(len(a))-1)). It is known as a slice.

print a[1:] >> [2, 3, 4]

#3

Thanks! Now I get it.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.