Python path-iterators and generators

Source: Internet
Author: User

Wedge

Suppose there is now a list of L = [' A ', ' B ', ' C ', ' d ', ' e '], and there are several ways to take the contents of the list

First, the index can be evaluated by l[0], followed by a for loop to take the value

Thinking: There is a subtle difference between using an index and a for loop to take a value.

If you use an index to take a value, you can take the value anywhere, but only if you know where the value is.

If you use a for loop to take a value, take each value, you do not need to care about the location of each value, because only the order of the value, and can not skip any one value, directly to the value of other locations.

But have you ever wondered why we can use a for loop to take a value?

How does the For loop work inside?

For loop in iterator python

Python path-iterators and generators

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.