Set Methods

set.clear()

Mutates the original set, so aliases observe the change. Remove all members without recursively changing those objects. Calling clear on an empty set is valid. Assigning a fresh set to a variable instead leaves aliases to the previous set unaffected. Do not iterate over a set while changing its size.

Formal Syntax & Structure

python syntaxpython
items.clear()

Return Value

None

The original set is emptied.

Working Example

Example Snippetpython
queue = {"build", "test"}alias = queueprint(queue.clear())print(len(alias), queue is alias)
Python Reference