A={'a','b','c'}
B={'a','y','z'}
A.symmetric_difference_update(B)
print(A)
Output
{'y', 'b', 'c', 'z'}
A={'a','b','c','x','y'}
B='Alex'
A.symmetric_difference_update(B)
print(A)
Output
{'y', 'l', 'A', 'e', 'b', 'a', 'c'}
Using list with symmetric_difference_update() method.
A={'a','b','c'}
B=['a','x','y']
A.symmetric_difference_update(B)
print(A)
Output
{'y', 'x', 'b', 'c'}
All set methods Questions with solutions on setAuthor
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.