Skip to content
Set Methods

update()

Add elements from all provided iterables to the set in place.

set.update(*others)

set.update() inserts all elements from one or more iterables into the calling set in place.

Duplicates are automatically ignored.

Parameters

NameDescription
*othersOne or more iterables containing elements to insert.

Returns

None — modifies the set in place.

Try it

Run it and change it
tags = {"python"}
tags.update(["fastapi", "django"], {"docker", "python"})
print(sorted(tags))

Worth knowing

  • In-place operator: set_a |= set_b is equivalent when both operands are sets.

Related entries