question about slicing with a step length

John Salerno johnjsal at NOSPAMgmail.com
Wed Mar 8 19:09:08 EST 2006


Given:

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

can someone explain to me why

numbers[10:0:-2] results in [10, 8, 6, 4, 2]?

I thought the first index, whether going forward or backward, was 
inclusive. And there is no index of 10 in this list, so what is it 
referring to?

Thanks.



More information about the Python-list mailing list