On Dec 10, 2:00 pm, "James Mills" <[EMAIL PROTECTED]>
wrote:
> On Wed, Dec 10, 2008 at 3:40 PM, dongzhi <[EMAIL PROTECTED]> wrote:
> > If I execute part[1], I have got  'a'. If I execute part[2], I have
> > got ' '. But, if I execute part[1::2], I have got ['a', '', '']. I
> > don't know why. Please tell me why.
>
> Perhaps you meant:
>
> part[1:2]
>
> pydoc list
>
> This will tell you there are 3 arguments to __getslice__
> i, j, y
>
> Without doing any further reading I
> presume from my experience that
> this works much like range and xrange
> and that the 3rd parameter is the step
> size.
>
> Consider this:
>
>
>
> >>> x = [9, 1, 2, 3, 4]
> >>> x
> [9, 1, 2, 3, 4]
> >>> x[1:2]
> [1]
> >>> x[1::2]
> [1, 3]
> >>> x[1::1]
> [1, 2, 3, 4]
> >>> x[1::2]
> [1, 3]
> >>> x[1::3]
> [1, 4]
>
> cheers
> James
>
> --
> --
> -- "Problems are solved by method

Dear James Mills,

Thanks a lot. Now, I know the reason.

Best Regards,

Liu Ming
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to