Python Slicing knowledge Daquan

Source: Internet
Author: User
Slice

Whether at work or in the process of interviewing, there are always a few things about slicing a collection and getting the part we want. Although this part is simple but important, the correct application can make you solve some complex problems more effectively. Let's take a formal study on slicing:

The prototype of the slice operator in Python is: [Start:stop:step]------- [start index: End index: Step value]

Start index : Same as other languages, starting from 0. Sequence from left to right, index of first value is 0, last one is-1

End Index : The slice operator is taken to the index and does not contain the value of the index

Step value : The default is one after the other, if it is 2, it means to take one operation. When the step value is positive, it is taken from left to right and, if negative, from right to left . The step value cannot be 0

Python Slicing knowledge Daquan

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.