Lists and Tuples store one or more objects or values in a specific order.
The objects stored in a list or tuple can be of any type including the nothing type defined by the None Keyword.
The main difference between lists and a tuples is the fact that lists are
mutable whereas tuples are
immutable.
Syntax Differences
Lists are surrounded by square brackets [] and Tuples are surrounded by parenthesis ().
a= [1,2,3,4]
b= (1,2,3,4)
Mutable List vs Immutable Tuples
List has mutable nature i.e., we can be changed or modified after its creation according to needs whereas tuple has immutable nature i.e., tuple can’t be changed or modified after its creation.
Remeber
- The literal syntax of tuples is shown by parentheses () whereas the literal syntax of lists is shown by square brackets [] .
- Lists has variable length, tuple has fixed length.
- List has mutable nature, tuple has immutable nature.
- List has more functionality than the tuple.