Table of Contents
1. Overview
The symmetric_difference_update() method finds the symmetric difference of two sets and updates the set calling it.
The symmetric difference of two sets A and B is the set of elements that are in either A or B, but not in their intersection.
The syntax of symmetric_difference_update()
is:
A.symmetric_difference_update(B)
2. Return Value from symmetric_difference_update()
- The
symmetric_difference_update()
returnsNone
(returns nothing). Rather, it updates the set calling it.
3. Example: Working of symmetric_difference_update()
A = {'a', 'c', 'd'} B = {'c', 'd', 'e' } result = A.symmetric_difference_update(B) print('A =', A) print('B =', B) print('result =', result)
Output
A = {'a', 'e'} B = {'d', 'c', 'e'} result = None
Here, the set A is updated with the symmetric difference of set A and B. However, the set B
is unchanged.
Recommended Reading: Python Set symmetric_difference()
Related posts:
Python String startswith()
Introduction to Scientific Programming with Python - Joakim Sundnes
Python super()
Python Program to Find the Sum of Natural Numbers
Python strptime()
Python timestamp to datetime and vice-versa
Python filter()
Python Program to Check If Two Strings are Anagram
Python String find()
Python Type Conversion and Type Casting
Python bin()
Python List reverse()
Python String rindex()
Python String isprintable()
Python @property decorator
Java Program to Implement the Binary Counting Method to Generate Subsets of a Set
Python Tuple index()
Python range()
Python Program to Display the multiplication Table
Deep Learning in Python - LazyProgrammer
Python max()
Python time Module
Python Dictionary pop()
Python Program to Display Calendar
Python String rstrip()
Python Program to Find HCF or GCD
Python complex()
Python String isalpha()
Python len()
Python Input, Output and Import
Python Set issuperset()
Python hex()