Students may find it confusing that Python has lists, tuples, and arrays. Which one should they use? Using lists will always work. Two important differences:
- Tuples are immutable (see M&C6). Applications that depend on performance may choose using tuples over lists.
- Arrays can contain arbitrary data, but all elements need to have the same type (e.g., all integers)
The table below gives a summary:
Array | List | Tuple | |
index | 0 to n-1 | 0 to n-1 | 0 to n-1 |
mutable | Yes | Yes | No |
data | homogeneous data | arbitrary data | arbitrary data |