Articles → Python → Sets In Python
Sets In Python
Purpose
Example
mySet = {1,2,3,4,5,2}
print(mySet)
Add Duplicate Elements In Sets
mySet = {1,2,3,4,5}
mySet.add(1)
print(mySet)
Converting The List To Set
mySet = {1,2,3,4,5}
myList = [1,2,1]
print(set(myList))
Output