A list is an ordered set of elements that can be added and removed at any time.
Define an empty list
>>> a_list=[]>>> a_list[]
Ordinary
>>> a_list=[1,2,3,4,5]>>> a_list[1, 2, 3, 4, 5]
Traverse
for inch a_list: ... Print 12345
Add Append: Adds an element at the end, adding only one at a time
>>> a_list.append ('Adele')>>> a_list[' Adele ']
Insert: Inserts at any location
>>> A_list.insert (1,'Taylor')>>> a_list[ ' Taylor ' ' Adele ']
Extend: The end is incremented, and the entire value of the other list
>>> a_list.extend (['1989','hello'])> >> a_list['Taylor'Adele' 1989'Hello']
Delete pop: Delete the last/specified position element, only one at a time
>>> A_list.pop () # default Delete last value 'hello'
>>> A_list.pop (1) # Specify delete location 'Taylor'
Remove: Removes the first occurrence of a value in the list
>>> a_list[' 1989'Adele'> >> a_list.remove (1)>>> a_list['1989' Adele']
Del: Delete one or several elements in succession
>>>delA_LIST[0]#Delete the specified element>>>a_list[2, 3, 4, 5,'1989','Adele']
>>>delA_list[0:2]#remove several elements in succession>>>a_list[4, 5,'1989','Adele']
>>>delA_list#Delete entire list>>>A_listtraceback (most recent): File"<stdin>", Line 1,inch<module>Nameerror:name'a_list' is notDefined
Sort and reverse order
>>> a_list.sort ()>>> a_list['1989 ' Adele']
Reverse order
>>> a_list[' 1989'Adele'> >> a_list.reverse ()>>> a_list['Adele' 1989', 5, 4, 3, 2, 1]
Several operators
>>> [1,2,3]+['a','b','C'][1, 2, 3,'a','b','C']
>>> ['Hello']*4['Hello','Hello','Hello','Hello']
>>> 1inch[A]true
Python:list usage