Set Methods

set.symmetric_difference_update()

Mutates the original set, so aliases observe the change. Retain members occurring on exactly one side, using a single supplied iterable. Repeated values in that iterable count as one member. The method accepts iterables rather than requiring set operands. Invalid iteration or hashing can raise exceptions. Do not assume transactional rollback on failure. Use the non-mutating counterpart when the original membership must be preserved.

Formal Syntax & Structure

python syntaxpython
items.symmetric_difference_update(other, /)

Parameters & Attributes

NameTypeDescription
otherIterable[Hashable]Iterable of candidate elements.

Return Value

None

Mutates the existing set; no new set is returned.

Working Example

Example Snippetpython
tags = {"red", "green"}alias = tagsprint(tags.symmetric_difference_update(["green", "blue", "blue"]))print(sorted(alias))
Python Reference