Python · Set operations

set.clear() / copy()

Remove every value, or create an independent shallow copy.

Syntax
items.clear() / items.copy()

Example

Open in the lab

More in this group

set.difference_update() set.intersection_update() set.isdisjoint() set.issuperset() set.pop() set.symmetric_difference_update() set.update()

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course