Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to Add Elements To a Set using add() method in python

mySet = {1, 2, 3}
mySet.add(4)
print(mySet)

# Output:
# {1, 2, 3, 4}

mySet2 = {1, 2, 3}
mySecondSet = {4, 5}
mySet2.update(mySecondSet)
print(mySet2)

# Output:
# {1, 2, 3, 4, 5}
Source by liu-111.medium.com #
 
PREVIOUS NEXT
Tagged: #How #Add #Elements #To #Set #method #python
ADD COMMENT
Topic
Name
8+8 =