Python Tuple vs List

Tuple vs List in Python

In this tutorial, we will learn the differences and common properties between a Python Tuple and Python List.

Following table contains information about tuple and list based on different properties.

PropertyTupleList
DefinitionImmutable collection of ordered items.Mutable collection of ordered items.
MutationImmutable. Items cannot be changed.Mutable. Items can be changed.
Append ItemCannot be done directly on the tuple. Work around has to be devised.Can append an item to the list.
Edit/Update ItemCannot be done directly on the tuple.Use index on the list and assign a new value.
Delete ItemTuple can be deleted entirely but not a single item from it.Can delete an item from the list. You may use del keyword.
Access ItemsItems can be accessed using index.Items can be accessed using index.
Iterate over ItemsYou may use for loop or while loop to iterate over items of Tuple.You may use for loop or while loop to iterate over items of Tuple.

From the above table, it is evident that the major difference between a Tuple and List in Python is that, Tuple is immutable while List is mutable. Mutable means, the collection can be mutated, like mutation in genetics, it accepts changes, hence changeable.

Summary

In this tutorial of Python Examples, we learned the differences and common features between List and Tuple in Python.

Related Tutorials

Code copied to clipboard successfully 👍