How to Add More Than One Item to a Set in Python


In this example we will show how to add more than one item to a set using the update() method in Python.

Source Code

my_set = {'a', 'b', 1, 'c'}

my_set.update([2, 'd', 3])
print(my_set)

Output:

{1, 2, 3, 'a', 'c', 'd', 'b'}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments