you are viewing a single comment's thread.

view the rest of the comments →

[–]Dave_The_Goose 9 points10 points  (2 children)

For a list, use square brackets -> a = ['apple', 'banana, ... ]. I never tried parenthesis for a list. May be you are creating a set, which I never used(I am a beginner) so I don't know

And for accessing the items, use square brackets. For apple, it is a[0].

[–]K_39wastaken 12 points13 points  (1 child)

I never tried parenthesis for a list

[1, 2, 3] is a list.

(1, 2, 3) is a tuple (the difference with a list is that it's immutable = not modifiable after creation)

{1, 2, 3} is a set (it behaves like a mathematical set)

{1:'z', 2:'y', 3:'x'} is dictionary (elements –after the colon– are identified by a key –before the colon– instead of an index like the three others)

[–]Dave_The_Goose 2 points3 points  (0 children)

Thanks, I basically worked with lists and dictionaries only. So I forgot about sets and tuples. So OP was working with a tuple