Enumerate (iterable,start=0)
(the subscript start position of the custom list) list variables, to define the number of open: default is 0 start
#!/usr/bin/env python#-*-coding:utf-8-*-a=["Juvenile","Youth","Adult","old age"] forKvinchEnumerate (a,1): Print(k,v)#Print 1 Teenager 2 Youth 3 adult 4 old
Enumerate () Combine the application, enter the life stage serial number, print out the corresponding stage
#!/usr/bin/env python#-*-coding:utf-8-*-a=["Juvenile","Youth","Adult","old age"] forKvinchEnumerate (a,1): Print(k,v) b=input ("Please enter the life stage number:") C=Int (b) d=A[c]Print(d)#input 1 Print youth
Range () automatically creates a list (py2.7 version)
(Automatically create list, less than how many start to create, greater than how many start to stop, create list interval number default can not write)
# !/usr/bin/env python # -*-coding:utf-8-*-a=range (1,11)print(a)#[1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
Xrange () Auto-Create list (py2.7 version)
Unlike range, xrange requires a for loop before it is created
# !/usr/bin/env python # -*-coding:utf-8-*-a=xrange (1,11) for in A: print(b )# Print 1 2 3 4 5 6 7 8 9
Range can also create a list from large to small
format : Ragne (max, Min, step)
Note: The decimal number itself cannot be taken, from large numbers to decimals whose step size is negative
such as: printing 10 9 8 7 6 5 4 3 2 1
Range (10,0,-1)
# !/usr/bin/env python # -*-coding:utf-8-*-a=range (10,0,-1) for in A: Print (b) # Print 9 8 7 6 5 4 3 2 1
The 13th lesson of Python Learning-other data types, others