Python Loop statement

Source: Internet
Author: User

The Python loop statement includes a for loop and a while loop

For Loop basic structure:

for var in values;

Looping statements

A variable iterates through all the values in a value, so values can be a set of numbers, or they can be traversed data types such as lists, tuples, collections, dictionaries, and so on, but the dictionary can only traverse its key when traversing

Values can also be generators (next write)

Else is also available in the For loop, but not commonly used

While loop basic structure:

While Judgment statement:

Looping statements

Executes the statement when the result is true (0 or non-null), or jumps out of the loop

Else can also be used in a while loop

Early conclusion:

Break jumps out of all loops

Continue terminates this cycle and continues with the next loop

Python Loop statement

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.