Difference Between List and Tuple in Python

By Mona Kumari|Updated : June 14th, 2022

Difference Between List and Tuple in Python: The list and tuple are the class of data structure of python. The list is dynamic, but the tuple has a static characteristic. The major difference between List and Tuple in Python is that list is dynamic in nature whereas the Tuple is not dynamic in nature.

Lists and Tuples are used to store one or more data types or python objects sequentially. Both can store any data such as float, integer, string, and dictionary. Lists and Tuples are similar in most factors, but we will describe the main difference between them.

Table of Content

Difference Between List and Tuple

The table shows the critical difference between List and Tuple. This table discusses the difference between List and Tuple based on methods, memory occupy, representation, nature, etc.

Key Differences Between List and Tuple

LIST

TUPLE

The list is mutable means suppose we have a list.

L=[1,2,3], and we have to add one more element than we add. 

The tuple is immutable means it, once declared, cannot expand. 

The list is dynamic in nature

Tuples are fixed size in nature. 

The list is enclosed in a square bracket[]. 

Tuples are enclosed in parenthesis(). 

The list can be used when the data is used frequently. 

The tuple can be used when data cannot be changed. 

There are several built-in methods in the list. 

The tuple does not have many built-in methods as list.

 List occupies more memory

Tuple occupies less memory as compared to list.

What is the List?

Before knowing the difference between List and Tuple, let us discuss the list. The list represents the group of elements. The list is very similar to an array, but the significant difference is that the list stores different types type of elements, whereas an array can store only one type of element.

The list contains different types of elements that can be modified. However, the list is dynamic, which means the size of the list is not fixed.

The syntax for creating the list is as follows:

List_name = [element1, element2, ………]

Example: list = [1, 2, 3, ‘BYJU’S’, -5]

 The syntax for creating the empty list is as follows:

List_name = []

Example: list = []

What is a Tuple?

Before knowing the difference between List and Tuple, let us discuss tuple. The tuple represents a group of elements that can be the same or different types. The tuples are similar to the list, but tuples are read-only, which means we cannot modify their elements. Therefore, the tuples occupy less memory as compared to the list.

The syntax for creating the empty tuple is as follows:

Tuple_name = ()

Example: tuple = ()

The syntax for creating the tuple is as follows:

We can create a tuple by writing the elements separated by commas inside the parenthesis().

Tuple_name = (element1, element2)

Example: tuple = (2, 3, ‘BYJU’S’, -5)

The syntax for creating the tuple with one element is as follows:

Tuple_name = (element1, element2)

Check out some important topics related to the difference between List and Tuple in the table provided below:

Difference between Compiler and InterpreterDifference between hackers and crackers
Difference between compounds and mixturesDifference between hardware and software
Difference between crystalline and amorphous solidsDifference between DELETE and TRUNCATE

Comments

write a comment

FAQs on Difference Between List and Tuple

  • The difference between List and Tuple is that the list is mutable means the List can be modified(delete or insert) after the declaration, whereas the tuple is immutable which means the Tuple cannot be modified.

  • The difference between List and Tuple regarding memory is that the list occupies more memory than the tuple because the List is dynamic, which means it can increase the size of the List, but the tuple is static.

  • Yes, the tuples are enclosed in parenthesis(), whereas the list are enclosed in a square bracket[]. we can declare the empty Tuple as tuple_name = () and the empty list as List_name = [].

  • No, the list can be used when the data is used frequently, whereas the tuple can be used when data cannot be changed. For example, Tuples are used to group related data, such as a person's name, age, and gender.

  • As per the nature of the function, the difference between List and Tuple is that list does not have fixed size in nature and is dynamic un nature whereas Tuple has fixed size and is not dynamic in nature.

Follow us for latest updates