List vs Tuple
A Python list can be changed after it is made; a tuple cannot.
List
An ordered, changeable collection in square brackets: [1, 2, 3].
Tuple
An ordered, unchangeable collection in round brackets: (1, 2, 3).
| List | Tuple | |
|---|---|---|
| Brackets | [ ] | ( ) |
| Can add or remove items | Yes: append, remove, pop | No |
| Can be a dictionary key | No | Yes |
| Use for | Things that change: a to-do list | Fixed records: a date, (x, y) point |
Example
marks = [70, 80]; marks.append(90) works. point = (3, 4); point[0] = 5 gives a TypeError.