Frozenset Methods
frozenset.symmetric_difference()
Keep members that occur on exactly one side, excluding those common to both. Repeated values in an iterable do not toggle membership repeatedly. Accepts exactly one other iterable. Returns a frozenset result without changing the receiver. The immutable receiver remains usable as a hashable key; do not rely on result identity. The method accepts iterable inputs such as lists or generators, unlike the built-in ^ operator between sets. Elements used in hashing must be hashable. Input iteration can raise exceptions; no ordering is guaranteed.
Formal Syntax & Structure
python syntaxpython
items.symmetric_difference(other, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| other | Iterable[Hashable] | Iterable of candidate elements. |
Return Value
frozenset
frozenset containing the calculated members.
Working Example
Example Snippetpython
a = frozenset({"read", "write"})b = a.symmetric_difference(["write", "export", "export"])print(sorted(b), type(b).__name__)print(sorted(a))