Difference between Tuple and List in Python at TCCI

Page 1

Difference between Tuple and List in Python at TCCI Definition Tuple and List are used to store data in Python Language. Tuple: A tuple is a collection of values and it is declared using parentheses. However, we can also use a tuple packing to do the same, and unpacking to assign its values to a sequence.

Lists: Unlike in C++, we don’t have arrays to work with in Python. Here, we have a list instead. 

Mutability o A List is Mutable o B Tuple is Immutable

In built Methods: o Following Methos can apply to List append(), insert(), remove(), pop(), clear(), sort(), and reverse(). o But not applicable to Tuple.

Inside Storage o We can store tuples in a list when we want to. For example, o [(1, ‘ABC’), (2, ‘DEF’), (3, ‘GHI’)]


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Difference between Tuple and List in Python at TCCI by Rosario Riley - Issuu