python add an element to a set code example
Example 1: add list to set python
set.update() or |=
>>> a = set('abc')
>>> l = ['d', 'e']
>>> a.update(l)
>>> a
{'e', 'b', 'c', 'd', 'a'}
>>> l = ['f', 'g']
>>> a |= set(l)
>>> a
{'e', 'b', 'f', 'c', 'd', 'g', 'a'}
Example 2: add element in set python
thisset = {"apple", "banana", "cherry"}
thisset.add("orange")
print(thisset)