Here are a few common list operations
adding elements
Adding elements using a built-in method for a list append
Number = [1, 2, 3, 4]
number.append (5) # number = [1, 2, 3, 4, 5]
number.append ([6,7]) # number = [1, 2, 3, 4, 5, [6, 7]]
Number.append ({' A ': ' B '}) # number = [1, 2, 3, 4, [6, 7], {' A ',: ' B '}
You can see a powerful Python list that can be nested in any type
Add list
To connect to two lists, you can use the + sign to connect
A = [1, 2, 3]
b = [4, 5, 6]
C = a + b # c = [1, 2, 3, 4, 5, 6]
You can also use the list built-in method extend to connect two lists
A = [1, 2, 3]
b = [4, 5, 6]
a.extend (b) # a = [1, 2, 3, 4, 5, 6]
Using the + number will create a new pass object, using extend to modify the original object
list to repeat
The list itself does not remove duplicate functionality, but it can be viewed with another type of Python set (Help (SET))
A = [1, 2, 3, 3,2, 1]
B = List (set (a)) # b = [1, 2, 3]
You can also use the built-in methods of the dictionary type
A = [1, 2, 2, 3, 1, 3]
B = {}.fromkeys (a). Keys () # b = [1, 2, 3]