# List vs Dictonary

Hi
I am doing Statistics Fundamentals course and i am on task 7 : Stratified Sampling . The part that i am having hard to understand is that in the exercise you have assigned a dictionary
points_per_position = {} but in the previous task no 5 : Simple Random Sampling you have assigned list sample_means =[] .
The part that i get most confused is when to use dictionary and when to use list.
I would really appreciate it if someone can help me clarify when to use dictionary and when you use list.

Thanks

Disclaimer before I answer: I havenâ€™t done that part of the course yet so the explanation I will give here applies to lists vs dictionaries in general. I know my Python so I can help there.

So, you would use a list if you just want a list of items and donâ€™t really need to associate every item in the list to something else. You would use a dictionary if you need a list of items but also need to associate each item with some other information.

Letâ€™s look at an example.

Example: Letâ€™s say there is a competition and at the end of the competition there are 3 winners. Rahul has 90 points, Mary has 60 points and Vik has 30 points.

If I ask for the winners you will give me a list: `winners = ['Rahul', 'Mary', 'Vik']`

If I ask for the points you will give me a list: `points = [90, 60, 30]`

If I ask for the points per winners or the points that every winner got, that is best expressed by a dictionary where you can associate the winner to the points. So you would have to use a dictionary: `points_per_winner = {'Rahul': 90, 'Mary': 60, 'Vik': 30]`

Now, back to this particular case. I would guess that with Random Sampling they just wanted the samples and they didnâ€™t need to associate each sample with anything else.

However, for `points_per_position` they needed not only the points but also the position to which each of those points is associated so you need a dictionary to express that association.

Does that make more sense? If not, please say so. I have a thousand different ways to explain any given concept.

1 Like

Thank you so much , it totally make sense .

1 Like

Yay!! And you are very welcome!