A={'a','b','c'}
B={'a','y','z'}
A.difference_update(B)
print(A)
Output
{'c','b'}
A={'a','b','c'}
B={'a','y','z'}
C={'a','c','l'}
A.difference_update(B,C)
print(A)
Output
{'b'}
A={'a','b','c','x','y'}
B='Alex'
A.difference_update(B)
print(A)
Output
{'c', 'y', 'a', 'b'}
Using list with difference_update() method.
A={'a','b','c'}
B=['a','x','y']
A.difference_update(B)
print(A)
Output
{'c', 'b'}
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.