Tutorials  Exercises  Get Certified  Services  Bootcamps Spaces Sign Up Log in
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)
 isdisjoint() Returns whether two sets have a intersection or not
 issubset() Returns whether another set contains this set or not
 issuperset() Returns whether this set contains another set or not
 pop() Removes an element from the set
 remove() Removes the specified element
 symmetric_difference() Returns a set with the symmetric differences of two sets
 symmetric_difference_update() inserts the symmetric differences from this set and another COLOR PICKER
 union() Return a set containing the union of sets
 update() Update the set with the union of this set and others
 
 ❮ Previous Log in to track progress Next ❯
 ADVERTISEMENT
 ADVERTISEMENT
 Spaces Upgrade Newsletter Get Certified Report Error
 Top Tutorials Top References Top Examples Get Certified
 HTML Tutorial HTML Reference HTML Examples HTML Certificate
 CSS Tutorial CSS Reference CSS Examples CSS Certificate
 JavaScript Tutorial JavaScript Reference JavaScript Examples JavaScript Certificate
 How To Tutorial SQL Reference How To Examples Front End Certificate
 SQL Tutorial Python Reference SQL Examples SQL Certificate
 Python Tutorial W3.CSS Reference Python Examples Python Certificate
 W3.CSS Tutorial Bootstrap Reference W3.CSS Examples PHP Certificate
 Bootstrap Tutorial PHP Reference Bootstrap Examples jQuery Certificate
 PHP Tutorial HTML Colors PHP Examples Java Certificate
 Java Tutorial Java Reference Java Examples C++ Certificate
 C++ Tutorial Angular Reference XML Examples C# Certificate
 jQuery Tutorial jQuery Reference jQuery Examples XML Certificate
 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.
 Copyright 1999-2023 by Refsnes Data. All Rights Reserved.
 W3Schools is Powered by W3.CSS.