- SET is the collection of unordered, unchangeable and unindexable items
- SET is the mutable data type, because we can add or remove items from set
- But set elements are immutable because we cannot change item after creation but can add more items.
- SET element stored in curly braces {}.
- Every element / items separated by comma.
- SET can contain only immutable data type element like integer, string etc
- When we store mutable data type like list, it will return TypeError exception.
- SET can be created using set() method.
- It take iterable object as argument
- It store unique elements
- It remove duplicated elements / items
- We can create empty set? using set() method
- School Bags
- Playlist
- Kitchen
- Dinner set
Modification of Element in SET
- We cannot modify an element of a set..
- We can add a element using the add() method
- To add multiple items, we use update() method.
- It take tuples, lists, strings or other sets as argument.
Duplication of Element in SET
- A set cannot contain duplicate items.
- Set() method remove automatically duplicate elements.