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