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 Functions
Python Dictionary copy()
Python Program to Illustrate Different Set Operations
Python Tuple index()
Python Set issubset()
Python String lower()
Python Program to Remove Punctuations From a String
Python String istitle()
Python Program to Display Fibonacci Sequence Using Recursion
Python Program to Find Armstrong Number in an Interval
Python break and continue
Python Program to Reverse a Number
How to Get Started With Python?
Python bytes()
Python Program to Count the Occurrence of an Item in a List
Python Program to Check the File Size
Python sorted()
Python Program to Delete an Element From a Dictionary
Python Program to Find the Factors of a Number
Python id()
Python getattr()
Python Machine Learning Third Edition - Sebastian Raschka & Vahid Mirjalili
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python Program to Find the Factorial of a Number
Python List extend()
Python String encode()
Python Namespace and Scope
Python Program to Convert String to Datetime
Python Program to Extract Extension From the File Name
Python Program to Swap Two Variables
Python Machine Learning Eqution Reference - Sebastian Raschka
Python classmethod()