In this chapter, we are going to look at a data structure you will be using extensively - arrays (called lists in Python).
Lists can comprise any data types (e.g.
string or even other
List types). Lists are similar to strings in the way that they are accessed by the index.
In this example, we are accessing index
2 of the list. Since the index starts from
0, at index
2, we have the element 3.
Similarly, we can iterate over lists using the
The below table has a few useful examples of methods we can use in Python lists.
a refers to a list in the below methods.
|Counts how many times x appears in the list|
|Remove x from list|
|Reverse the order of the list|
|Sort the list in ascending order, add |