##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
You know lists and dicts. Now meet tuples (immutable sequences) and sets (unique collections).
Two new collection types
Immutable sequences
Parentheses syntax
Parentheses are optional
Single-element gotcha
Indexing like lists
Extracting portions
The restriction that helps
What tuples prevent
Build your first tuple
Grouping values together
Extracting values at once
The * operator
Variable assignment
Classic unpacking trick
Functions returning tuples
Tuple return practice
Using immutability
Choosing the right type
Unique elements only
Curly braces syntax
Use set(), not {}
Empty set creation
Unique and unordered
The add() method
remove() vs discard()
remove vs discard
Add without duplicates
The in operator
Entry problem for sets
Sets eliminate duplicates
The code
summary
Combining two sets
Elements in both sets
What's in A but not B
Elements in exactly one set
Intersection result
Union and intersection
Set intersection application
Intersection of character sets
The code
summary
Keep first occurrence only
Track seen elements
The code
summary
Find the first non-repeating
Count then scan
The code
summary
Immutable sets
list(), tuple(), set()
What conversion preserves
Convert and process
When sets are faster
Summary of when to use what
What we learned