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
| Name | Description |
|---|---|
| *others | One 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_bis equivalent when both operands are sets.