🌐
GeeksforGeeks
geeksforgeeks.org › python › differences-and-applications-of-list-tuple-set-and-dictionary-in-python
Differences and Applications of List, Tuple, Set and Dictionary in Python - GeeksforGeeks
October 3, 2025 - Tuples are ideal for grouping data of different types like user records. ... A Python set is an unordered collection of unique elements. It is mutable, meaning you can add or remove elements (only regular sets), and it supports mathematical operations like union, intersection, and difference. ... Regular sets (set) are mutable and therefore not hashable. They cannot be used as dictionary keys or stored inside other sets.
🌐
Medium
medium.com › @arun.verma8007 › python-data-structures-56d4211ca5a7
List, Tuple, Set, Dictionary in Python | Medium
September 14, 2022 - Tuple use less memory than list with same elements. Set is unordered and doesn’t contain duplicate. ... Set and Dictionary provide very good performance over other data structures.
Discussions

When should I use a list, dictionary, tuple, or set in Python?
IMO: and this is controversial but will greatly help you organize your data, don't lump tuples in with lists, dictionaries, and sets. A tuple isn't a collection, it's a type. That is, use a tuple when your single object has multiple properties. Like a name or a coordinate. A first and last name together form a name, they don't have much value separately, and the constitute the entirely of the object. In this sense, a tuple of first_name, last_name is a single object, not a collection of separate strings. For example, a CSV file is "best" represented as a list of tuples. Each line is a single thing, but with multiple properties all of which are related. Column 1 and column 2 of a row aren't really a sequence or or collection, but rather feathers on the same chicken (tuple). However, Row 1 and row 2 are related only in that they are the same kind of thing stored together (list). We put the tuples in the list because the parts of the row are more related than the rows of the document. Think about type-hinting a tuple vs a list: a list hint takes exactly one type, and the expectation is that there will be several objects of that type. Conversely, a tuple hint easily accepts multiple types, but needs to know the exact number and position of each type. It's not so much that a tuple is an immutable container, but that a tuple stores an immutable thing. List: Use it when you need to store a lot of the same thing. It's ordered, but it doesn't need to be limited to ordered sequences. That is, a list is generally okay as long as the items don't need to be unordered. A list is good at iterating, but bad at selection, so use it when you will be looping over the items, but not selecting at random. Tuple: A tuple is one thing. You generally don't use it for storage, but for structure. When you have a thing with multiple parts, that's a tuple. When you have multiple things, that's a list. Unlike a list, a tuple is very likely to contain different types, while a list is (should) contain elements of a single type. Again, a tuple is good at iteration and bad at selection. A dictionary and set are really close to the same thing--they are hashes. Hashes are bad at iteration, but good at selection, so they are best when you need to select items from the container at random--not in order. They are semi-ordered, meaning you can now expect the order to remain, but if you need items to be in order it's probably not the right type. If you need a key->value relationship, then you want a dict, otherwise, you want a set. Use lists when order matters and you need to modify elements. Order doesn't need to matter, it just needs to be inconsequential. Also, avoid the "modify" criteria as almost all "real" collections are modifiable. Lists end up being sort of a "default", so without a reason to choose something else, or a reason to avoid a list, most of the time a list is fine. Use tuples when you need an immutable sequence (e.g., function return values). Again, look at this as a single object. Use tuples when you are returning a complex single object, not a sequence. You can return a list from a function just as easily as a tuple, so I don't consider return values a good selection criteria. However, your function should be returning "one thing", so in that sense a tuple makes sense, but from the other direction. Use sets when you need fast lookups and uniqueness. Use dictionaries when mapping keys to values efficiently. again, I would avoid thinking about sets and dictionaries as a top-level division. Instead, think "do I need a hash", and then "do I need key->value pairs" to choose between them. Is this not actually a collection of separate, but similar, objects? Then you want a tuple, or something more sophisticated like a NamedTuple, DataClass, or Class Is this a sequence? That is, do you need these items in order, or don't care about which one you get next, or will be dealing with all the items at once (even if one-by-one)? This is a list. Is this more of a "soup"? Where you want a specific item next, and don't care about order, or will be dealing with only specific objects at once? More on reddit.com
🌐 r/learnpython
24
100
March 6, 2025
Beginner to python: Lists, Tuples, Dictionaries, Sets - Stack Overflow
I have been trying to understand what the difference is between lists, tuples, dictionaries, and sets. All I've been able to gather is they use different brackets or braces. () {} []. Some are able... More on stackoverflow.com
🌐 stackoverflow.com
When to use sets, tuples, lists, or disctionaries?
Simple answer: You use lists when you have an ordered collection of things that you'll want to update. You use tuples when you want a list you can't change. You use Dictionaries when you have a collection of label, value pairs. You use sets when you have an unordered collection of unique things. Special considerations on sets: Sets are faster to look up values in than lists and you can use boolean set algebra to fiddle with them, so if you have a collection of unique things where order doesn't matter and you want to do stuff with you probably want a set. More on reddit.com
🌐 r/learnpython
4
6
November 3, 2020
Why doesn't dict.items() and dict.keys() return a list?

What is the benefit of these objects?

A list has to load all its data into memory before doing anything. These objects just reference the underlying dict, not duplicating anything. This means that they are less memory-hungry and that, if you are apt to exit the loop quickly, you didn't pay to copy everything beforehand.

To me they just seem to introduce unnecessary complexity to my code.

It is one more thing to keep in mind, and I share your skepticism about its value. Ultimately, few will share it.

FWIW, numpy.array does more guessing than your average nice function, and this leads to a lot of stuff like this. I'm not sure that there is a nice API it could provide that didn't have such hiccups sometimes, though.

More on reddit.com
🌐 r/Python
83
76
March 29, 2016
People also ask

What is a Tuple in Python?
A Tuple in Python refers to the collections of various objects of Python separated by commas between them. Tuples are similar to the lists in terms of repetition, nested objects, and indexing. The difference is that a tuple, unlike a list, is immutable.
🌐
testbook.com
testbook.com › home › key differences › difference between list, tuple, set, and dictionary in python | testbook.com
Difference Between List, Tuple, Set, and Dictionary in Python | ...
What is the main difference between list and tuple in python?
The main difference is that lists are mutable (can be changed), while tuples are immutable (cannot be changed).
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › difference between list, tuple, set, and dictionary in python
Understanding List, Tuple, Set, Dictionary in Python with Examples
Can I use a tuple as a dictionary key?
Yes, since tuples are immutable, they can be used as dictionary keys, unlike lists, which are mutable and cannot be used as keys.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › difference between list, tuple, set, and dictionary in python
Understanding List, Tuple, Set, Dictionary in Python with Examples
🌐
Medium
medium.com › @sankhasubhra.das.uemk.cse.2023 › list-tuple-set-dictionary-in-python-53056d2a1ad0
List, Tuple, Set & Dictionary in Python | by Sankha Subhra | Medium
September 1, 2023 - Tuple: Maintains order of elements. Set: No guaranteed order. Dictionary: Insertion order is preserved in Python 3.7+.
🌐
Jadubaba Tech
jadubabatech.wordpress.com › 2025 › 04 › 09 › list-tuple-set-and-dictionary-in-python
List, Tuple, Set, and Dictionary in Python – Jadubaba Tech
April 9, 2025 - Use tuples when you need a fixed collection of items. Use sets when you need unique elements and no duplicates. Use dictionaries when you want to associate values with unique keys.
🌐
Scaler
scaler.com › home › topics › python › differences between list, tuple, set and dictionary in python
Difference between list, tuple, set dictionary in Python
April 2, 2024 - A set is an unordered collection that can store multiple values, contains only unique elements, and does not allow duplicates. A dictionary stores data in key-value pairs, where each key is unique and used to access its corresponding single value. These four data types are extremely important ...
🌐
BYJUS
byjus.com › gate › difference-between-list-tuple-set-and-dictionary-in-python
Difference Between List, Tuple, Set, and Dictionary in Python
September 30, 2022 - The difference is that a tuple, unlike a list, is immutable. The lists, on the other hand, are mutable. The sets are an unordered collection of data types. These are mutable, iterable, and do not consist of any duplicate elements.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › difference between list, tuple, set, and dictionary in python
Understanding List, Tuple, Set, Dictionary in Python with Examples
September 1, 2025 - This guide has equipped you with ... in Python. Remember: use lists for ordered, mutable collections; tuples for fixed, immutable data; sets for unique items; and dictionaries for fast, key-value lookups....
Find elsewhere
🌐
DEV Community
dev.to › ussdlover › lists-tuples-dictionaries-and-sets-in-python-3npj
Lists, Tuples, Dictionaries, and Sets in Python - DEV Community
May 31, 2023 - Tuples are similar to lists but are immutable, meaning they cannot be modified after creation. They are denoted by parentheses or by simply separating items with commas. Tuples are often used to represent a collection of related values that ...
🌐
Testbook
testbook.com › home › key differences › difference between list, tuple, set, and dictionary in python | testbook.com
Difference Between List, Tuple, Set, and Dictionary in Python | Testbook.com
The difference is that a tuple, unlike a list, is immutable. A Set in Python is an unordered collection of data types. These are mutable, iterable, and do not consist of any duplicate elements.
🌐
Dataquest
dataquest.io › home › blog › python data structures: lists, dictionaries, sets, tuples
Python Data Structures: Lists, Dictionaries, Sets, Tuples – Dataquest
May 12, 2025 - Tuples are similar to lists, but are immutable; they can be used as data containers that we do not want to modify by mistake. ... I am a doctoral researcher in bioinformatics and food sciences at the University of Turku, Finland.
🌐
Javatpoint
javatpoint.com › tuple-to-dictionary-in-python
Tuple to Dictionary in Python - Javatpoint
Tuple to Dictionary in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
Sustainabilitymethods
sustainabilitymethods.org › index.php › Lists,_Tuples,_Sets,_and_Dictionaries_in_Python
Lists, Tuples, Sets, and Dictionaries in Python - Sustainability Methods
This means that I can choose the elements in my nested tuple with these squared brackets. The order of the brackets follow the same order as the nesting. The first bracket determines the element within the larger tuple, and the second one within the chosen tuple. Dictionaries are similar to lists, but it has unique indexes.
🌐
Reddit
reddit.com › r/learnpython › when should i use a list, dictionary, tuple, or set in python?
r/learnpython on Reddit: When should I use a list, dictionary, tuple, or set in Python?
March 6, 2025 -

Hey everyone,

I’m trying to get a deeper understanding of Python’s built-in data structures—specifically lists, dictionaries, tuples, and sets. I understand their basic properties:

Lists (list) → Ordered, mutable, allows duplicates

Tuples (tuple) → Ordered, immutable, allows duplicates

Dictionaries (dict) → Key-value pairs, unordered (but ordered since Python 3.7), keys must be unique

Sets (set) → Unordered, mutable, unique elements only

But I'm struggling to figure out when to use each of them in real-world scenarios. I know some general guidelines, like:

Use lists when order matters and you need to modify elements.

Use tuples when you need an immutable sequence (e.g., function return values).

Use sets when you need fast lookups and uniqueness.

Use dictionaries when mapping keys to values efficiently.

However, I’d love to hear from experienced Python developers:

Are there any specific patterns or real-world examples where one of these structures is clearly the best choice?

Have you ever misused one and later realized another structure would have been better?

Are there any performance considerations that I should be aware of when choosing between them?

Looking forward to your insights! Thanks in advance.

Top answer
1 of 15
69
IMO: and this is controversial but will greatly help you organize your data, don't lump tuples in with lists, dictionaries, and sets. A tuple isn't a collection, it's a type. That is, use a tuple when your single object has multiple properties. Like a name or a coordinate. A first and last name together form a name, they don't have much value separately, and the constitute the entirely of the object. In this sense, a tuple of first_name, last_name is a single object, not a collection of separate strings. For example, a CSV file is "best" represented as a list of tuples. Each line is a single thing, but with multiple properties all of which are related. Column 1 and column 2 of a row aren't really a sequence or or collection, but rather feathers on the same chicken (tuple). However, Row 1 and row 2 are related only in that they are the same kind of thing stored together (list). We put the tuples in the list because the parts of the row are more related than the rows of the document. Think about type-hinting a tuple vs a list: a list hint takes exactly one type, and the expectation is that there will be several objects of that type. Conversely, a tuple hint easily accepts multiple types, but needs to know the exact number and position of each type. It's not so much that a tuple is an immutable container, but that a tuple stores an immutable thing. List: Use it when you need to store a lot of the same thing. It's ordered, but it doesn't need to be limited to ordered sequences. That is, a list is generally okay as long as the items don't need to be unordered. A list is good at iterating, but bad at selection, so use it when you will be looping over the items, but not selecting at random. Tuple: A tuple is one thing. You generally don't use it for storage, but for structure. When you have a thing with multiple parts, that's a tuple. When you have multiple things, that's a list. Unlike a list, a tuple is very likely to contain different types, while a list is (should) contain elements of a single type. Again, a tuple is good at iteration and bad at selection. A dictionary and set are really close to the same thing--they are hashes. Hashes are bad at iteration, but good at selection, so they are best when you need to select items from the container at random--not in order. They are semi-ordered, meaning you can now expect the order to remain, but if you need items to be in order it's probably not the right type. If you need a key->value relationship, then you want a dict, otherwise, you want a set. Use lists when order matters and you need to modify elements. Order doesn't need to matter, it just needs to be inconsequential. Also, avoid the "modify" criteria as almost all "real" collections are modifiable. Lists end up being sort of a "default", so without a reason to choose something else, or a reason to avoid a list, most of the time a list is fine. Use tuples when you need an immutable sequence (e.g., function return values). Again, look at this as a single object. Use tuples when you are returning a complex single object, not a sequence. You can return a list from a function just as easily as a tuple, so I don't consider return values a good selection criteria. However, your function should be returning "one thing", so in that sense a tuple makes sense, but from the other direction. Use sets when you need fast lookups and uniqueness. Use dictionaries when mapping keys to values efficiently. again, I would avoid thinking about sets and dictionaries as a top-level division. Instead, think "do I need a hash", and then "do I need key->value pairs" to choose between them. Is this not actually a collection of separate, but similar, objects? Then you want a tuple, or something more sophisticated like a NamedTuple, DataClass, or Class Is this a sequence? That is, do you need these items in order, or don't care about which one you get next, or will be dealing with all the items at once (even if one-by-one)? This is a list. Is this more of a "soup"? Where you want a specific item next, and don't care about order, or will be dealing with only specific objects at once?
2 of 15
27
Tuple example below: I work with a lot of spatial information (latitudes, longitudes, etc.) whenever I’m processing this information I always make sure it is stored as a tuple because I don’t want to ever accidentally mess with that information since it’s tied to a specific place that someone cares about. Being off by X amount could be a big deal.
Top answer
1 of 2
1

List and tuple are similar to dynamic arrays where in list are mutable but tuples are not. You could checkout the documentation for list and tuple https://docs.python.org/3.8/library/stdtypes.html#sequence-types-list-tuple-range

A set is an unordered collection of objects. Link to the docs: https://docs.python.org/3.8/library/stdtypes.html#set-types-set-frozenset

A dict maps hashable values to arbitrary objects. Mappings are mutable objects. Link to the docs: https://docs.python.org/3.8/library/stdtypes.html#mapping-types-dict

2 of 2
0
  1. List : Used to store the items. Duplicates can also be stored. Order of storing will be maintained as is. It is mutable which means the same object can be altered after creation. Example :

    list1 = ['one',2,3.4,'hello']
    print(list1)
    print(list1[3])
    list1[1]=2 #allowed
    print(list1)
    

    Answer:

        'one', 2, 3.4, 'hello']
        hello
        [2, 2, 3.4, 'hello']
    
  2. Set : Just like list. Only difference is it cannot store the duplicate values. Also there will be no order in which values are stored.

Example:

>>>#set of integers
>>>s = {1, 2, 3}
>>>print(s)
{1, 2, 3}
>>>#print type of s 
>>>print(type(s))
<class 'set'>
>>> x = set(['foo', 'bar', 'baz', 'foo', 'qux'])
>>> x
{'qux', 'foo', 'bar', 'baz'}
  1. Dictionary : Dictionary is basically a storage type in which you can store a value corresponding to a key just like a real life dictionary.

Example:

>>>dictval = {"Nishant":1,"Akash":2,"Ravi":3,"Hari":4}
>>>print(dictval)
{'Nishant': 1, 'Akash': 2, 'Ravi': 3, 'Hari': 4}
>>>print(dictval["Akash"])
2
  1. Tuple: A tuple is a sequence of values much like a list. The values stored in a tuple can be any type, and they are indexed by integers. The important difference is that tuples are immutable.That we can’t change the elements of tuple once it is assigned whereas in the list, elements can be changed.

Example:

>>>#tuple with mixed datatypes
>>>t = (1, 'raju', 28, 'abc')
>>>print(t)
>>>print(t[1])
(1, 'raju', 28, 'abc')
raju

>>>t = (1, 'raju', 28, 'abc')
>>>print(t)
>>>print(t[3])
>>>t[3] = 'def'
(1, 'raju', 28, 'abc')
abc
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-27-254e32ad7a3c> in <module>()
      2 print(t)
      3 print(t[3])
----> 4 t[3] = 'def'
TypeError: 'tuple' object does not support item assignment
🌐
NamasteDev
namastedev.com › home › technology & development › python › data types & variables › lists, tuples, sets, dictionaries
Lists, Tuples, Sets, Dictionaries - Python
July 31, 2025 - Remember that Python uses zero-based indexing: ... Append: Adds an element at the end of the list. ... Insert: Inserts an element at a specified position. ... Remove: Removes the first occurrence of a specified value. ... Sort: Sorts the list in ascending order. ... Tuples are similar to lists in that they are ordered collections of items; however, they are immutable.
🌐
Medium
medium.com › @thepycoder › understanding-python-collections-list-tuple-set-and-dictionary-explained-cc750ccca519
🐍 “Understanding Python Collections: List, Tuple, Set, and Dictionary Explained” | by Shashivendra Yadav | Medium
July 5, 2025 - my_tuple = (1, 2, 3, 2) # my_tuple[0] = 10 # ❌ Error: tuple is immutable print(my_tuple) # (1, 2, 3, 2) Use When: You need only unique items; order doesn’t matter. ... Use When: You need to map keys to values. ... my_dict = {"name": "Naman", "role": "Python Developer"} my_dict["role"] = "AI Engineer" print(my_dict) # {'name': 'Naman', 'role': 'AI Engineer'}
🌐
Medium
medium.com › @menkashah060 › mastering-python-collection-list-tuple-dictionary-and-set-explained-with-examples-16c0965c8506
📚Mastering Python Collection: List, Tuple, Dictionary, and Set Explained with Examples | by Menkashah | Medium
April 8, 2025 - Strings are immutable in Python. So when you change the string, a new object is created in memory. a = "hello" print(id(a)) # e.g., 123456 a += " world" print(id(a)) # e.g., 789101 (different!) A tuple is an ordered, immutable collection. Once defined, it cannot be changed. colors = ('red', 'green', 'blue') print(colors[0]) # Output: red ... A dictionary is an unordered, mutable collection of key-value pairs.
🌐
Du
cs.du.edu › ~intropython › byte-of-python › data_structures.html
Lists, Tuples, Dictionaries, and Sets · HonKit
We specify that we want to remove the first item from the list and hence we use del shoplist[0] (remember that Python starts counting from 0). If you want to know all the methods defined by the list object, see help(list) for details. Tuples are used to hold together multiple objects.
🌐
Python 101
python101.pythonlibrary.org › chapter3_lists_dicts.html
Chapter 3 - Lists, Tuples and Dictionaries — Python 101 1.0 documentation
To reiterate, the code above casts the tuple (abc) into a list using the list function. A Python dictionary is basically a hash table or a hash mapping. In some languages, they might be referred to as associative memories or associative arrays. They are indexed with keys, which can be any immutable type. For example, a string or number can be a key. You need to be aware that a dictionary is an unordered set of key:value pairs and the keys must be unique.
🌐
Educative
educative.io › answers › list-vs-tuple-vs-set-vs-dictionary-in-python
List vs. tuple vs. set vs. dictionary in Python
Tuples are enclosed within parentheses. Sets: A set is an unordered collection. Sets are represented in curly brackets. Dictionaries: A dictionary is an unordered collection of data that stores data in key-value pairs.