Python Sets

Last updated:
set1 = set([1, 2, 'a', True, 3.14])
set1.add(12)
set1.remove(20) --> KeyError
set1.discard(20) --> silent

set1.union(set2)
set1.intersection(set2)

2 in set1
>>> True
'b' in set1
>>> False

Comments

No comments!