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.
Arguments
Parameters
| Name | Description |
|---|---|
| *others | One or more iterables containing elements to insert. |
Result
Returns
None, modifies the set in place.
Run it
Try it
Run it and change it
tags = {"python"}
tags.update(["fastapi", "django"], {"docker", "python"})
print(sorted(tags)) Output
Press Run to see what it prints.Worth knowing
- In-place operator:
set_a |= set_bis equivalent when both operands are sets.