Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Difference Between List and Tuple in Python
Next article icon

Difference Between List and Tuple in Python

Last Updated : 13 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In Python, lists and tuples both store collections of data, but differ in mutability, performance and memory usage. Lists are mutable, allowing modifications, while tuples are immutable. Choosing between them depends on whether you need to modify the data or prioritize performance and memory efficiency.

Key Differences between List and Tuple

S.No

List

Tuple

1Lists are mutable(can be modified).Tuples are immutable(cannot be modified).
2Iteration over lists is time-consuming.Iterations over tuple is faster
3Lists are better for performing operations, such as insertion and deletion.Tuples are more suitable for accessing elements efficiently.
4Lists consume more memory.Tuples consumes less memory
5Lists have several built-in methods.Tuples have fewer built-in methods.
6Lists are more prone to unexpected changes and errors.Tuples, being immutable are less error prone.

Mutability Test: List vs Tuples

List are Mutable

Lists can be modified, meaning their elements can be changed, added or removed after creation.

Python
a = [1, 2, 4, 4, 3, 3, 3, 6, 5]  # Modifying an element in the list `a` a[3] = 77 print(a) 

Output
[1, 2, 4, 77, 3, 3, 3, 6, 5] 

Explanation: Here, we modified the fourth element (index 3) from 4 to 77. Lists allow direct modification of their elements.

Tuples are Immutable

Tuples cannot be modified after creation. Any attempt to change an element will result in an error.

Python
b = (0, 1, 2, 3)  # Attempting to modify a tuple b[0] = 4 print(b) 


Hangup (SIGHUP)
Traceback (most recent call last):
File "/home/guest/sandbox/Solution.py", line 4, in <module>
b[0] = 4
~^^^
TypeError: 'tuple' object does not support item assignment

Explanation: Tuples do not support item assignment, making them immutable. This prevents unintended modifications.

Performance Comparison: Lists vs Tuples

Memory Efficiency Test

Since tuples are stored in a single memory block and do not require additional space for dynamic changes, they are more memory-efficient than lists.

Python
import sys  # Creating an empty list and tuple a = [] b = ()  # Assigning values a = ["Geeks", "For", "Geeks"] b = ("Geeks", "For", "Geeks")  # Checking memory usage print(sys.getsizeof(a)) print(sys.getsizeof(b)) 

Output
88 64 

Explanation: This code shows that the list takes more memory than the tuple. Tuples, being immutable, require less overhead, making them a better choice for storing fixed data.

Iteration Speed Test

Tuples have a performance advantage in iterations because they are immutable and stored in a contiguous memory block, reducing overhead.

Python
import time  # Creating a large list and tuple a = list(range(100000001)) b = tuple(range(100000001))  # Timing tuple iteration start = time.time_ns() for i in range(len(b)):     x = b[i] end = time.time_ns() print(end - start)  # Timing list iteration start = time.time_ns() for i in range(len(a)):     x = a[i] end = time.time_ns() print(end - start) 

Output

16649292352 
12447795073

Explanation: Tuples iterate faster than lists as they are stored in a single memory block, while lists need extra operations for dynamic resizing.

Operations - Lists vs Tuples

In Python, both lists and tuples support a range of operations, including indexing, slicing, concatenation, and more. However, there are some differences between the operations that are available for lists and tuples due to their mutability and immutability, respectively.

Indexing

Both lists and tuples allow you to access individual elements using their index, starting from 0.

Python
a = [1, 2, 3] # list  b = (4, 5, 6) # tuple  print(a[0])  print(b[1]) 

Output
1 5 

Slicing

Both lists and tuples allow you to extract a subset of elements using slicing.

Python
a = [1, 2, 3, 4, 5] b = (6, 7, 8, 9, 10)  print(a[1:3]) print(b[:3]) 

Output
[2, 3] (6, 7, 8) 

Concatenation

Both lists and tuples can be concatenated using the "+" operator.

Python
# List Concatenation a = [1, 2, 3] b = [4, 5, 6] print(a + b)  # Tuple Concatenation a = (7, 8, 9) b = (10, 11, 12) print(a + b) 

Output
[1, 2, 3, 4, 5, 6] (7, 8, 9, 10, 11, 12) 

List-Specific operations

Only lists support operations that modify their contents:

  • Append: Adds an element at the end.
  • Extend: Merges another list.
  • Remove: Removes the first occurrence of a value.
Python
a = [1, 2, 3]  a.append(4)  a.extend([5, 6])  a.remove(2) print(a) 

Output
[1, 3, 4, 5, 6] 

Explanation: append(4) method adds the number 4 to the end of the list, making it [1, 2, 3, 4]. Next, the extend([5, 6]) method adds multiple elements [5, 6] to the list, updating it to [1, 2, 3, 4, 5, 6]. The remove(2) method then deletes the first occurrence of 2 from the list, resulting in [1, 3, 4, 5, 6]

When to Use Tuples Over Lists?

In Python, tuples and lists are both used to store collections of data, but they have some important differences. Here are some situations where you might want to use tuples instead of lists:

  • Immutability: Tuples are immutable, ensuring data integrity by preventing modifications. Ideal for constants, configurations, and fixed data.
  • Performance: Tuples are faster and more memory-efficient than lists as they are stored in a single block and don’t require extra space for modifications.
  • Memory Efficiency: Tuples use contiguous memory, while lists need extra space for dynamic resizing, making tuples a better choice for large, unchanging datasets.



Next Article
Difference Between List and Tuple in Python

S

SHUBHAMSINGH10
Improve
Article Tags :
  • Python
  • Difference Between
Practice Tags :
  • python

Similar Reads

    Difference between List and Array in Python
    In Python, lists and arrays are the data structures that are used to store multiple items. They both support the indexing of elements to access them, slicing, and iterating over the elements. In this article, we will see the difference between the two.Operations Difference in Lists and ArraysAccessi
    6 min read
    Difference between List and Dictionary in Python
    Lists and Dictionaries in Python are inbuilt data structures that are used to store data. Lists are linear in nature whereas dictionaries stored the data in key-value pairs. In this article, we will see the difference between the two and find out the time complexities and space complexities which ar
    6 min read
    Difference between for loop and while loop in Python
    In this article, we will learn about the difference between for loop and a while loop in Python. In Python, there are two types of loops available which are 'for loop' and 'while loop'. The loop is a set of statements that are used to execute a set of statements more than one time. For example, if w
    4 min read
    Create a List of Tuples in Python
    The task of creating a list of tuples in Python involves combining or transforming multiple data elements into a sequence of tuples within a list. Tuples are immutable, making them useful when storing fixed pairs or groups of values, while lists offer flexibility for dynamic collections. For example
    3 min read
    Python - Accessing nth element from tuples in list
    We are given tuples in list we need to access Nth elements from tuples. For example, we are having a list l = [(1, 2), (3, 4), (5, 6)] we need to access the Nth element from tuple suppose we need to access n=1 or 1st element from every tuple present inside list so that in this case the output should
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences