Python for statement

Source: Internet
Author: User

Python for statement

The For loop accesses all elements in an iterative object, such as a sequence or iterator, and ends the loop after all entries have been processed. Its syntax is as follows:
For Iter_var in iterable:
Suite_to_repeat
Each time the loop, the Iter_var iteration variable is set to iterate over the current element of the object (sequence, iterator, or other object that supports iterations), which is provided to the SUITE_TO_REPEAT statement block for use.

1. Loop iteration Sequence object As String

 for inch ' Girl ' :     Print ' Current Letter : ', I

2. Loop iteration Sequence object as list (tuple)

L = ['my','name',' is','  Jake'] for in L:  print' current Word:', I

3. Range ()

 for  in range (1,10):  Print i

4, continue

 for  in range (1,10):  print  i  if i = 5:  Continue

Python for 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.