Python learning daily-slicing & iterating & list generation

Source: Internet
Author: User

Slices: As the name implies, is to cut one thing into pieces, and the slice in Python is to cut the array into a piece of

L=list (range (1,100));

L (f:e:p) #f代表开始切的位置, E represents the end position (but not including), and p represents the cut interval.

For example L (10:26:2) represents starting from the 10th bit (i.e. starting from the number 11) to 26 end (that is, the number 27), but excluding the 26th bit, where the interval is 2.

Slicing is also supported from the back cut such as L ( -10:-1:none) is from the bottom 10th bit to start cutting to the last one.

It is important to note that the three parameters of a slice are all default.

Iteration: A very simple concept, which can continue to be segmented, is iterative in nature. For example, l=123 is not iterative because he is a number, and l= ' 123 ' is iterative because he is a string.

List generation: That is, a formula-like code snippet with the following structure:

[The number of generated formats generated (represented by a for loop) satisfies the condition (if, can default)]

For can occur multiple times, one layer contains one layer of relationships.

Python learning daily-slicing & iterating & list generation

Related Article

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.