Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Merging one set into another set (update)

objects  = set(['Mars', 'Jupiter', 'Saturn'])
internal = set(['Mercury', 'Venus', 'Earth', 'Mars'])

objects.update(internal)
print(objects)
print(internal)

Output:

{'Mars', 'Earth', 'Jupiter', 'Saturn', 'Mercury', 'Venus'}
{'Earth', 'Mars', 'Mercury', 'Venus'}