List slicing


I don't understand how the slicing works. well the syntax is list_name[start, end, stride], but are start and end included in the new list? and does the counting start AT 'start'?

Replace this line with your code.


yes, the counting starts at start, if we have:

print "test"[0:2]

we would get: te (indexes: 0 and 1). 2 is not included, since it is lesser then 2. Think of list slicing as a loop, so we start at zero, and 2 is not included since we use lesser then < and not lesser or equal (<=)


Thanks for explaining it with the loop idea!