Set
Set
ConversionCreating a set
from an array
would be a O(n)
operation.
Creating an array
(list) from set
would also be a O(n)
operation.
newList = {"one", "two", "three"} newSet = set(newList)
Nested iteration
# creating set from list (array) my_list = [[2, 4], [2, 6], [2, 8]] my_set = {e for l in my_list for e in l}