THE WORLD'S LARGEST WEB DEVELOPER SITE

Python Set update() Method

❮ Set Methods


Example

Insert the items from set y into set x:

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}

x.update(y)

print(x)
Run example »

Definition and Usage

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

If an item is present in both sets, only one appearance of this item will be present in the updated set.


Syntax

set.update(set)

Parameter Values

Parameter Description
set Required. The set insert into the current set

❮ Set Methods