How to Use Set symmetric_difference_update() Method in PythonPython Basics


The symmetric_difference_update() method updates the set with the symmetric difference of two given sets.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

A = {1,4,5,6,11}
B={1,5,6,7,9,11,12}
C={22,1,34,4}
print(A.symmetric_difference_update(B))
print(A)

print(B.symmetric_difference_update(C))
print(B)

Output:

None
{4, 7, 9, 12}
None
{34, 4, 5, 6, 7, 9, 11, 12, 22}

Syntax

set_x.symmetric_difference_update(set_y)

Parameters

set_x — one set

set_y — another set

Return Value

It doesn’t return any value.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us