Create a list of

1. The basic syntax [] Create
A = [10,20, 'Luis', Frank']
A = [] # Create an empty list object
2.list () created
using the list () any data can be converted iteration said list.
a = list () # Create an empty list of objects
A = List (Range (10))
A
[0,1,2,3,4,5,6,7,8,9]
A = List ( "Luis, Frank ")
3.range () to create a list of integers
range () can help us to very easily create a list, which is extremely useful in the development, the syntax is:
the Range ([Start] End [the STEP])
Start parameters: optional indicating the starting number, the default is 0
end parameters: required, identification numbers ending
step parameters: Alternatively, represents the step size of a default
in the rang python3 () returns a target range, rather than a list, we need list () method to convert it into a list of objects
typical example is as follows:
list (Range (3,15,2))
[3,5,7,8,11,13]
list (Range (15, 3, -1))
[15,14,13,12,11,10,9,8,7,6,5,4]

Guess you like

Origin www.cnblogs.com/fenglius/p/12098805.html