python for loop traversing the second element

University students in the afternoon just to ask how I do, for a time thought up. Later, he wrote out I asked a question. As shown below

This is taken syntax. . . what. Awkward, strings, lists are supported intercepted. Interception syntax:

Slice syntax: [start: end: step], step 1 by default may be negative, the slice interval left and right to open and close

Exercise 1: All traverse

company = [ "Sun", "Taobao","Baidu", "Google"]
for site in company:
        print(site)

 Export

Sun
Taobao
Baidu
Google

Exercise 2: The second element traversal

company = [ "Sun", "Taobao","Baidu", "Google"]
for site in company[1:]:
       print(site)

 

Export

Taobao
Baidu
Google

Sometimes thought to be active point ah. . .

Published 221 original articles · won praise 207 · views 170 000 +

Guess you like

Origin blog.csdn.net/qq_29720657/article/details/103995335