How to Insert Items in One Set Into Another in Python


In this example, we will learn how to insert the items in one set into another using the update() method in Python.

Source Code

set1 = {'apple', 'banana', 'orange'}
set2 = {'cow', 'sheep', 'pig'}

set1.update(set2)
print(set1)

Output:

{'orange', 'sheep', 'pig', 'cow', 'apple', 'banana'}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement