Python - Set Methods
Python - Set Methods
Dark mode
Dark code
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP BOOTSTRAP HOW TO W3.CSS C C++ C# REACT R JQUERY DJANGO
yt o to
Python Get Started
ADVERTISEMENT
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Numbers
Python Casting
Python - Set Methods
Python Strings
Python Booleans
❮ Previous Next ❯
Python Operators
Python Lists
Python Tuples
Set Methods
Python Sets
Python Sets Python has a set of built-in methods that you can use on sets.
Access Set Items
Method Description
Add Set Items
Remove Set Items add() Adds an element to the set
Loop Sets
clear() Removes all the elements from the set
Join Sets
copy() Returns a copy of the set
Set Methods
Set Exercises difference() Returns a set containing the difference between two or more sets
Python Dictionaries
difference_update() Removes the items in this set that are also included in another, specified set
Python If...Else
Python While Loops discard() Remove the specified item
Python For Loops
intersection() Returns a set, that is the intersection of two other sets
intersection_update() Removes the items in this set that are not present in other, specified set(s)
symmetric_difference_update() inserts the symmetric differences from this set and another COLOR PICKER
update() Update the set with the union of this set and others
❮ Previous Log in to track progress Next ❯
ADVERTISEMENT
ADVERTISEMENT
FORUM | ABOUT
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.