[Tutor] How does slicing work?
Emile van Sebille
emile at fenx.com
Sat Jun 16 05:54:41 CEST 2012
On 6/15/2012 7:48 PM Kanone Seele said...
> Hello,I'm a beginner in python.I found some qustions in Chapter 9's Quiz
> of the book/Learning Python,4th ed/,
>
>> >> L = [1, 2, 3, 4]
>
>> >> L[-1000:100]
>
> [1, 2, 3, 4]
>
>> >> L[3:1]
>
> []
>
>> >> L[3:1] = ['?']
>
>> >> L
>
> [1, 2, 3, '?', 4]
>
>
> How does python get the result of slicing?Such as the examples
> above,they really confused me.
>
>
There's some good examples at:
http://stackoverflow.com/questions/509211/good-primer-for-python-slice-notation
HTH,
Emile
More information about the Tutor
mailing list