If you’re learning and exploring python, you’ve definitely encountered the concepts of List vs Tuple vs Set in python. When exploring these three concepts at first time, it looks similar like storing multiple values, but in reality they are designed for different purposes.
In this article, we’ll explore Python Lists, Tuples and Sets with easy concepts, simple examples, practical use cases and comparison table. It will help you find the right data structure as your need.
What Are List, Tuple and Set in Python?
Python provides various built-in data structure for storing collections of data. They are useful for minimizing the size of code and reducing the memory size which helps in easy retrieval of datas.
These three are the most commonly used data structures in python:
- List
- Tuple
- Set
What Is a List In Python?
A list is one of the most popular and common data structure used in python. It is an ordered and mutable collection of elements. It provides several functions that helps to manipulate or retrieval of elements.
A list allows you to:
- Store multiple values with their different data types
- Helps in maintaining thier order
- Add new values
- Remove values
- Modify existing values
- Store duplicate values
Let’s understand how a List stores elements in Python with the help of the following illustration:


students = ["Ram", "Shyam", "Sita"]
print(students)Note: Lists are created using square brackets [].
Output:
['Ram', 'Shyam'What Is a Tuple in Python?
A tuple is an ordered but immutable collection. A tuple is an ordered and immutable collection of elements in Python. Unlike a list, once a tuple is created, its elements cannot be changed, added, or removed. Tuples are commonly used to store data that should remain unchanged.
A tuple allows you to:
- Store multiple values with different data types
- Maintain the order of elements
- Access elements using indexing
- Store duplicate values
- Keep data unchanged after creation
- Store related values together
students = ("Ram", "Shyam", "Sita")
print(students)Note: Tuples are created using parentheses ().
Output:
('Ram', 'Shyam', 'Sita')What Is a Set in Python?
A set is an unordered and mutable collection of unique elements in Python. It automatically removes duplicate values and provides several methods for performing operations such as adding, removing, and comparing elements.
A set allows you to:
- Store multiple values with different data types
- Store only unique values
- Automatically remove duplicate values
- Add new values
- Remove values
- Perform set operations such as union, intersection, and difference
- Check whether an element exists in the set
students = {"Ram", "Shyam", "Sita"}
print(students)Note: Sets are created using curly braces {}.
Output:
{'Ram', 'Shyam', 'Sita'}List vs Tuple vs Set in Python: Comparison Table
Now, Let’s explore List, Tuple and Set with the following comparison table. It summarizes the main features of all these three data structures in python. It allows you to choose the right one for your code.
| Feature | List | Tuple | Set |
|---|---|---|---|
| Syntax | [] | () | {} |
| Ordered | Yes | Yes | No indexing |
| Mutable | Yes | No | Yes |
| Duplicates | Allowed | Allowed | Not Allowed |
| Indexing | Yes | Yes | No |
| Modify Elements | Yes | No | N/A |
| Add Element | Yes | No | Yes |
| Remove Element | Yes | No | Yes |
| Main Purpose | General Collection | Fixed Data | Unique Data |
What Are The Common Methods Used In List in Python?
Python provides many useful methods for adding, removing, searching, and sorting elements which stored in the form of List data structure. It helps to perform various functions easily.
These are the commonly used methods and their description in list:
| Methods | Description |
|---|---|
| append() | It is used to adds an item to the end of a list |
| extend() | It is used to add multiple items in a list |
| insert() | It is used to add an item at a specific postion |
| index() | It is used to position of an item |
| sort() | It is used to sort the items |
| pop() | It is used to removes and return an item |
| clear() | It is used to remove all items |
| count() | It is used to counts how many times an item appears |
What Are The Common Methods Used In Tuple in Python?
A Tuple is an ordered and immutable collection. Since tuples cannot be modified after creation, they have fewer methods than lists.
| Methods | Description |
|---|---|
| count() | It is used to counts how many times a value appears |
| index() | It is used to returns the index of a value |
What Are The Common Methods Used In Set in Python?
A Set is a mutable collection that stores unique values. Sets are particularly useful for removing duplicates, checking membership, and performing operations such as union and intersection.
| Methods | Description |
|---|---|
| add() | It is used to add an item to the set |
| update() | It is used to add multiple items in the set |
| union() | It is used to combine two or more sets |
| intersection() | It is used to return common elements |
| diffrence() | It is used to return elemets that are different |
Conclusion
Every coder need to understand the difference between List, Tuple, and Set in Python is essential for writing clean and efficient Python code. Use a List when you need ordered and changeable data, a Tuple for fixed data, and a Set when you need unique values.
Choosing the right data structure depends on what your program needs. The right choice can make your code cleaner, easier to manage, and more efficient, while also helping you use memory more effectively. Contact LetsLearn today to learn more about Python Training and start your programming journey.
Contact Information:
Contact Number: 01-5923180, 9841117580
Email:info@letslearn.asia
Address: SRD Complex, New Plaza Rd, Kathmandu
A List is mutable and ordered, a Tuple is immutable and ordered, while a Set stores unique values.
Both Lists and Tuples allow duplicate values. Sets do not.
Lists and Sets are mutable, while Tuples are immutable.
No. Sets do not support indexing because they are not sequence types.
Tuples can be slightly more memory-efficient and faster in some operations, but the main reason to use a Tuple is when the data should not change.
Use a List when you need ordered data that may change during program execution.
Use a Tuple when you need ordered data that should remain unchanged.
Use a Set when you need unique values or frequent membership checks.
numbers = [1, 2, 2, 3, 3]
unique_numbers = set(numbers)
print(unique_numbers)
my_set = set()






