how to view a set python code example
Example 1: python set
# A set contains unique elements of which the order is not important
s = set()
s.add(1)
s.add(2)
s.remove(1)
print(s)
# Can also be created from a list (or some other data structures)
num_list = [1,2,3]
set_from_list = set(num_list)
Example 2: get length of set python
# Create a set
seta = {5,10,3,15,2,20}
# Or
setb = set([5, 10, 3, 15, 2, 20])
# Find the length use len()
print(len(setb))