x = [1, 2, 3]
0
):e = x[1] # e == 2
+
operator to concatenate two lists. Example:x = [1, 2] + [3, 4] # x == [1, 2, 3, 4] x = ["a", "b"] x += ["c"] # x == ["a", "b", "c"]
['a', 'b', 'c', 'd'][1:3] # ['b', 'c'] ['a', 'b', 'c', 'd'][::2] # ['a', 'c'] ['a', 'b', 'c', 'd'][3:0:-1] # ['d', 'c', 'b']
Members
append
None
list.append(item)
Parameters
Parameter | Description |
---|---|
item
|
required Item to add at the end. |
clear
None
list.clear()
extend
None
list.extend(items)
Parameters
Parameter | Description |
---|---|
items
|
required Items to add at the end. |
index
int list.index(x, start=None, end=None)
Parameters
Parameter | Description |
---|---|
x
|
required The object to search. |
start
|
int; or None ;
default is None The start index of the list portion to inspect. |
end
|
int; or None ;
default is None The end index of the list portion to inspect. |
insert
None
list.insert(index, item)
Parameters
Parameter | Description |
---|---|
index
|
int;
required The index of the given position. |
item
|
required The item. |
pop
unknown list.pop(i=-1)
index
is specified, it removes and returns the last item in the list.
Parameters
Parameter | Description |
---|---|
i
|
int; or None ;
default is -1 The index of the item. |
remove
None
list.remove(x)
Parameters
Parameter | Description |
---|---|
x
|
required The object to remove. |