Variables
Sets in Python
Used to store values like an array and ensure there are no duplicates.
Syntax
set_name = set([value1, value2]) #initialize set with values
set_name = set() #initialize set without values
set_name.add(value3) #add value to a set
Notes
The order of a set is not guaranteed.
Sets can be combined, using union (| symbol), intersection (& symbol), difference (- symbol), and symmetric difference (^ symbol).
The keywords 'in' and 'not in' can be used to check for the existence of values in a set.
Example
integers = set([1, 2, 3, 4, 5])
integers.add(6)