May 2017
Intermediate to advanced
310 pages
8h 5m
English
Lists are probably the most used built-in data structures in Python because they can be composed of any number of other data types. They are a simple representation of arbitrary objects. Like strings, they are indexed by integers starting with zero. The following table contains the most commonly used list methods and their descriptions:
|
Method |
Description |
|
list(s) |
Returns a list of the sequence s. |
|
s.append(x) |
Appends element x to the end of s. |
|
s.extend(x) |
Appends the list x to s. |
|
s.count(x) |
Counts the occurrence of x in s. |
|
s.index(x, [start], [stop]) |
Returns the smallest index, i, where s[i] ==x. Can include optional start and stop index for the search. |
|
s.insert(i,e) |
Inserts x at index i. |
Read now
Unlock full access