Python Set update() Method

Example

Insert the items from set y into set x:

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
x.update(y) 
print(x)

Running an Example

Definition and Usage

The update() method updates the current set by adding items from another set.

If an item exists in both sets, the updated set will only contain that item once.

Syntax

set.update(set)

Parameter Values

Parameters Description
set Required. Insert the set into the current set.