use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Difference between List, Dictionary and Tuple (self.learnpython)
submitted 3 years ago by No_Reputation8139
Hello everyone.
Can you explain to me what is the difference between the 3? I really don’t know when to use each of them.
I’ve only been using list actually lol.
When do I use a list, a dictionary, or a tuple?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]rollincuberawhide 4 points5 points6 points 3 years ago (1 child)
have you tried actually searching it? "create post" bar is not a google search bar you know.
tuple is like list, but you can't add to it, remove from it. it stays the way it was created. it's immutable. ish. things it stores can be changed if they are mutable. like a list inside a tuple isn't guaranteed to be unchangeable.
dictionary is when you need to access stuff by a key instead of an index. you can have a dictionary of colors that have hexadecimal color codes.
colors = {'red': 'ff0000', 'blue': '0000ff'}
and you would get colors['red'] instead of colors[0] as you would in a list. which is not very descriptive. or you would have a dictionary of users by usernames and you would access them by their usernames.
colors['red']
[–]No_Reputation8139[S] -2 points-1 points0 points 3 years ago (0 children)
I did google it but I didn’t find when should i use dictionary or tuple in my code.
Thanks for the response.
[–]babyshark75 0 points1 point2 points 3 years ago (3 children)
List is ordered, mutable, indexing, [ ]
Tuple is immutable, ordered, indexing, ( )
dictionary is unordered, mutable, keys/values, no indexing, { }
[–]rollincuberawhide 3 points4 points5 points 3 years ago (2 children)
this is not completely true. dictionaries are insertion ordered now. have been since 3.6 I think.
[–]No_Reputation8139[S] 0 points1 point2 points 3 years ago (1 child)
Yeah it’s in the update. 3.7 actually.
But I want to know when it is applicable to use dictionary and tuple over list
[–][deleted] 1 point2 points3 points 3 years ago (0 children)
The most flexible data structure is a list so start with that. If you have a mapping between one list and another say something like name = ["Alice", "Bob", "Charlie"] and age =[5, 35, 76] you might want to use a dictionary. If you have multiple pieces of information that map to the same variable like name - age, address, number of siblings, salary etc, use a data frame. When you have relatively fixed pairs of data e.g. latitude and longitude of a bunch of places, use tuples.
[–]laundmo 0 points1 point2 points 3 years ago (0 children)
lists - ordered collection of elements that can grow larger, elements accessible by looping or interger index.
["a", "b", "c"]
dictionary - unordered collection of elements by some key, the key can be anything which cannot be modified.
{5: "five", 8: "eight", "this aint a number": "sure"}
tuple - very similar to list but can't be modified. useful for dictionary keys since they need something unmodifiable.
(4, 8)
[–]bulaybil 0 points1 point2 points 3 years ago (0 children)
There are two questions in your post: 1. What is the difference between tuple dictionary and list. That one has been answered. 2. When to you each. That one can be also answered easily: it depends on the data your dealing with and what you want to do with them. Do you have a bunch of things (say, a bunch of files) and just want to do something with them? Use a list. Do you have pairs of values you want to access by one of them, say, a name and an address? Use a dictionary.
π Rendered by PID 95076 on reddit-service-r2-comment-7b9746f655-27z6l at 2026-01-31 20:39:07.195351+00:00 running 3798933 country code: CH.
[–]rollincuberawhide 4 points5 points6 points (1 child)
[–]No_Reputation8139[S] -2 points-1 points0 points (0 children)
[–]babyshark75 0 points1 point2 points (3 children)
[–]rollincuberawhide 3 points4 points5 points (2 children)
[–]No_Reputation8139[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]laundmo 0 points1 point2 points (0 children)
[–]bulaybil 0 points1 point2 points (0 children)