Enumerate
You can automatically generate a column for the list, starting from 0, and automatically growing by 1, you can specify a default start value
List_product = ["ThinkPad", "MacBook", "Iphone8", "Robbit"]for key,v in Enumerate (list_product,1): print (KEY,V)
Range 2.7 To get the number in the specified range
1. Range (0,1000000), all data is created in memory at once
2, Xrange,xrange (0,100000), only in the loop output, only one time to create data
Python 3 has only a range equal to the function of the xrange in 2.7, with a range of 0 to 10, and a default step of 1
For T in range (1,10): print (t)
All even numbers of output 1-10
For Oushu in range (0,11,2): print (Oushu)
Output 1-10 all odd numbers
For Jishu in range (1,11,2): print (Jishu)
Output 10,9,8,7....0
For I in Range (10,0,-1): print (i)
Python in enumerate, xrange, range