Lists or Dictionaries?

ok so im trying to make a double elimination tournament bracket wizard and my idea was to make two lists(or dictionaries) one represents the winners bracket, the other would be the losers bracket. And if a team loses they get moved from the winners bracket to the losers bracket, and if they lose while there in the losers bracket they are eliminated.
so my question is should i use lists or dictionaries?

You should use dictionaries if you need to refer to the teams using something other than a number and need to associate that with a value, like an inventory system would need (item name and how many of each). I would use an array for this purpose.

winners = ['red', 'blue', 'green']
losers = ['yellow', 'black', 'white']

I made a python tutorial on my youtube channel with dictionaries and lists:



Figure out from those which one would be more useful in your situation! :slight_smile: Good luck.

Dictionaries are more organized than lists btw. I’d probably use dictionaries for slots on an inventory.

Essentially, I think of it this way- lists are better for nameless things (a list of vertices in a mesh, for example) or something you want organized linearly (inventory slots for example- slot 1, then slot 2, etc) whereas dictionaries are better for storing things with names that you might not want to access in a linear fashion (for example, a bunch of competitors- they each have their own unique name, and you’ll want to access them via the name, rather than remembering which index in the list they’re on)

List can sort, dictionary can’t directly, so if you’d want to sort by wins, stats or anything that would be a reason to use list.

Otherwise dict is more powerful.

From what you describe clearly:

lists of teams

But you are not specific enough. You didn’t not tell how you want to access (identify) the teams in your data structure.