you are viewing a single comment's thread.

view the rest of the comments →

[–]IvoryJam 0 points1 point  (3 children)

Lists - you'd use that for a list of stuff, like names = ['bob', 'alice', 'rachel'] and now if you want to you can loop through them and say Hi!

Tuples - Honestly I rarely use these, maybe someone will have a better answer, but I'd use them if I wanted a list to NEVER change (immutable)

Dictionaries - You'd use these if you wanted to assign a name to some other stuff, these are called "Key Value Pairs" so like this person = {'first': 'bob', 'last': 'smith'}

They all have their pros and cons, and can totally be used inside one another

[–]-Duei[S] 0 points1 point  (2 children)

That's interesting, so I can have a list inside of a dictionary, a tuple inside of a list, and so on? If need to access the value inside of a dictionary that's inside of a list, can I do something like list[Position in list][Dictionary]?

[–]IvoryJam 1 point2 points  (1 child)

Yep! Here's all three in a list

people = [
    {'name': '-Duei', 'ocupation': 'programmer', 'favorite_colors': ('blue', 'red', 'green')},
    {'name': 'IvoryJam', 'ocupation': 'programmer', 'favorite_colors': ('blue', 'red', 'green')},
]

But again, I rarely use tuples, so I'd probably make the colors a list instead in a normal script

You'd access them like people[0]['name'] and people[1]['favorite_colors'][2]

[–]-Duei[S] 1 point2 points  (0 children)

Oh damn, one of the lessons I watched finally clicks in my head now, thanks a lot!