← BYTES
Python·Starter·Ref: 6.1.17
How does a set differ from a list in Python?
Have a question about this video? Mention reference 6.1.17 when you contact us.
a.A set preserves insertion order while a list does not
b.Sets can only contain numbers, lists can contain anything
c.A set automatically stores only unique elements and has no guaranteed indexing/ordering, while a list can contain duplicates and is ordered/indexable
d.They are functionally identical, just different syntax
A set like `{1, 2, 3}` automatically deduplicates (adding an existing value is a no-op) and doesn't support indexing by position, whereas a list preserves insertion order, allows duplicates, and supports `list[i]` indexing.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES6117#Python