The list function converts a sequence of other types to a list, such as
>>> list ("Hello World")
[' H ', ' e ', ' l ', ' l ', ' o ', ' ', ' w ', ' O ', ' r ', ' L ', ' d ']
Element assignments can change the list, such as
>>> Sen
[' H ', ' e ', ' l ', ' l ', ' o ', ' ', ' w ', ' O ', ' r ', ' L ', ' d ']
>>> sen[0] = ' H '
>>> Sen
[' H ', ' e ', ' l ', ' l ', ' o ', ' ', ' w ', ' O ', ' r ', ' L ', ' d ']
Use Del to remove elements from the list, such as
>>> Sen
[' H ', ' e ', ' l ', ' l ', ' o ', ' ', ' w ', ' O ', ' r ', ' L ', ' d ']
>>> del Sen[0]
>>> Sen
[' E ', ' l ', ' l ', ' o ', ', ' w ', ' O ', ' r ', ' L ', ' d ']
Shard assignments can assign values to multiple elements at once, such as
>>> Sen
[' E ', ' l ', ' l ', ' o ', ', ' w ', ' O ', ' r ', ' L ', ' d ']
>>> Sen[:3] = List ("HHhH")
>>> Sen
[' H ', ' h ', ' h ', ' h ', ' o ', ' ', ' w ', ' O ', ' r ', ' L ', ' d ']
A shard assignment can also insert a sequence, such as
>>> sen = list ("World")
>>> sen[0:0] = list ("Hello")
>>> Sen
[' H ', ' e ', ' l ', ' l ', ' o ', ' ', ' w ', ' O ', ' r ', ' L ', ' d ']
Append--Append a new object to the end of the list and modify the original list directly
Count--count the number of occurrences of an element in the list
Extend--Append multiple values of another sequence at the end of the list, modifying the original list directly
>>> sen = list ("World")
>>> sen.extend (' er ')
>>> Sen
[' W ', ' O ', ' r ', ' L ', ' d ', ' e ', ' R ']
Index--Find out from the list where the first match of a value is indexed
>>> Sen
[' W ', ' O ', ' r ', ' L ', ' d ', ' e ', ' R ']
>>> Sen.index (' R ')
2
Insert--Inserts an object into the list
Pop-Removes an element from the list (the last one by default) and returns the value of the element
>>> Sen
[' W ', ' O ', ' r ', ' L ', ' d ', ' e ', ' R ']
>>> Sen.pop ()
' R '
>>> Sen
[' W ', ' O ', ' r ', ' L ', ' d ', ' e ']
>>> Sen.pop (0)
' W '
Nameerror:name ' Seb ' is not defined
>>> Sen
[' O ', ' r ', ' L ', ' d ', ' e ']
Remove-Removes the first occurrence of a value in the list
>>> Sen
[' O ', ' r ', ' L ', ' d ', ' e ']
>>> sen.remove (' l ')
>>> Sen
[' O ', ' R ', ' d ', ' e ']
Reverse--returning the elements from the list to the home store
Sort-Sorts the list at the original location, returning a null value
Sorted--Gets a sorted copy of the list, which is used for any sequence
>>> sen_sorted = sorted (sen)
>>> sen_sorted
[' d ', ' e ', ' o ', ' R ']
>>> Sen
[' O ', ' R ', ' d ', ' e ']
A list of the basic Python tutorial notes