The traversal of the Python list data

Source: Internet
Author: User

Way One:

App_list = [1234, 5677, 8899]<!--lang:python-->for app_id in app_list:<!--lang:python--    print app_i D

Output:
1234
5677
8899

Way two:

App_list = [1234, 5677, 8899]<!--lang:python-->for index,app_id in Enumerate (app_list):<!--Lang:python--> ;    Print Index, app_id

Output:
0 1234
1 5677
2 8899

Method Three: Use Range () or xrange ()

App_list = [1234, 5677, 8899]<!--Lang:python--    i in range (len (app_list)):<!--Lang:python-->
   
    print I,app_list[i]
   

Output:
0 1234
1 5677
2 8899

Mode four: Using ITER ()

App_list = [1234, 5677, 8899]<!--lang:python-->for app_id in ITER (app_list):<!--Lang:python--    print app_id

Output:
1234
5677
8899

The traversal of the Python list data

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.