Python : Lists and Tuples

What is the Difference between a List and a Tuple?

  • Both lists and tuples are sequence data types that can store a collection of items.
  • You can also access any item by its index.
  • The main difference between lists and a tuples is the fact that lists are mutable whereas tuples are immutable.

Immutable object

An immutable object (unchangeable1 object) is an object whose state cannot be modified after it is created.

A mutable object (changeable object), which can be modified after it is created.

Lists

>>> list_a = ['a', 'b', 'c']

tuple

>>> tuple_a = ('a', 'b', 'c')