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.

Property Tuple List
Definition Immutable collection of ordered items. Mutable collection of ordered items.
Mutation Immutable. Items cannot be changed. Mutable. Items can be changed.
Append Item Cannot be done directly on the tuple. Work around has to be devised. Can append an item to the list.
Edit/Update Item Cannot be done directly on the tuple. Use index on the list and assign a new value.
Delete Item Tuple can be deleted entirely but not a single item from it. Can delete an item from the list. You may use del keyword.
Access Items Items can be accessed using index. Items can be accessed using index.
Iterate over Items You 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

Privacy Policy Terms of Use

SitemapContact Us