Difference between Tuple and List in Python tccicomputercoaching.com

Page 1

Difference between Tuple and List in Python tccicomputercoaching.com 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 o

A List is Mutable B Tuple is Immutable

 In built Methods: o o

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

 Inside Storage o o

We can store tuples in a list when we want to. For example, [(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 tccicomputercoaching.com by Rosario Riley - Issuu