0% found this document useful (0 votes)
67 views

Python Set Methods: Tutorials References Exercises Menu Paid Courses

The document discusses various methods that can be used on Python sets. It lists common set methods like add(), remove(), pop(), union(), intersection(), symmetric_difference(), and others. Each method is described briefly, explaining what it does to a set, such as adding or removing elements, finding intersections or differences of multiple sets, updating one set with another, and more.

Uploaded by

Kittin Kaglai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Python Set Methods: Tutorials References Exercises Menu Paid Courses

The document discusses various methods that can be used on Python sets. It lists common set methods like add(), remove(), pop(), union(), intersection(), symmetric_difference(), and others. Each method is described briefly, explaining what it does to a set, such as adding or removing elements, finding intersections or differences of multiple sets, updating one set with another, and more.

Uploaded by

Kittin Kaglai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

3/11/22, 4:24 AM Python Set Methods

 Tutorials  References  Exercises  Menu  Log in

Website NEW Paid Courses


Dark mode

Dark code
  HTML CSS JAVASCRIPT   

Python Set Methods


❮ Previous Next ❯

Python has a set of built-in methods that you can use on sets.

Method Description

add() Adds an element to the set

clear() Removes all the elements from the set

copy() Returns a copy of the set

difference() Returns a set containing the difference between two or more sets

difference_update() Removes the items in this set that are also included in another, specified
set

discard() Remove the specified item

intersection() Returns a set, that is the intersection of two or more 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

union() Return a set containing the union of sets

update() Update the set with another set, or any other iterable

https://www.w3schools.com/python/python_ref_set.asp 1/4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy