René's URL Explorer Experiment


Title: Sets in Python – Real Python

Open Graph Title: Sets in Python – Real Python

Description: Learn how to work effectively with Python sets. You’ll define set objects, explore supported operations, and understand when sets are the right choice for your code.

Open Graph Description: Learn how to work effectively with Python sets. You’ll define set objects, explore supported operations, and understand when sets are the right choice for your code.

Mail addresses
?subject=Python article for you&body=Sets in Python on Real Python https://realpython.com/python-sets/

Opengraph URL: https://realpython.com/python-sets/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "Sets in Python",
  "image": {
    "@type": "ImageObject",
    "url": "https://files.realpython.com/media/UPDATE-Sets-in-Python_Watermarked.29cc4fe84b78.jpg",
    "width": 1920,
    "height": 1080
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://realpython.com/python-sets/",
    "lastReviewed": "2025-05-05",
    "author": {
      "@type": "Person",
      "name": "Leodanis Pozo Ramos",
      "image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
      "url": "https://realpython.com/team/lpozoramos/",
      "affiliation": {
        "@type": "Organization",
        "@id": "https://realpython.com/#organization",
        "name": "Real Python",
        "url": "https://realpython.com",
        "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
      }
    },
    "reviewedBy": [
      {
        "@type": "Person",
        "name": "Aldren Santos",
        "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
        "url": "https://realpython.com/team/asantos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Brenda Weleschuk",
        "image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
        "url": "https://realpython.com/team/bweleschuk/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Bartosz Zaczy\u0144ski",
        "image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
        "url": "https://realpython.com/team/bzaczynski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "David Amos",
        "image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/me-small.f5f49f1c48e1.jpg",
        "url": "https://realpython.com/team/damos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Joanna Jablonski",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/jjablonksi-avatar.e37c4f83308e.jpg",
        "url": "https://realpython.com/team/jjablonski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "John Sturtz",
        "image": "https://realpython.com/cdn-cgi/image/width=1920,height=1920,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/real-python-logo-square.28474fda9228_1.146e987bf77c.png",
        "url": "https://realpython.com/team/jsturtz/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      }
    ]
  },
  "datePublished": "2025-05-05T14:00:00+00:00",
  "dateModified": "2025-05-05T14:09:20.163980+00:00",
  "publisher": {
    "@type": "Organization",
    "@id": "https://realpython.com/#organization",
    "name": "Real Python",
    "url": "https://realpython.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
      "width": 512,
      "height": 512
    },
    "description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
    "slogan": "Become a Python Expert",
    "email": "info@realpython.com",
    "sameAs": [
      "https://github.com/realpython",
      "https://www.youtube.com/realpython",
      "https://twitter.com/realpython",
      "https://x.com/realpython",
      "https://www.linkedin.com/company/realpython-com/",
      "https://www.facebook.com/learnrealpython",
      "https://www.instagram.com/realpython",
      "https://www.tiktok.com/@realpython.com"
    ]
  },
  "author": {
    "@type": "Person",
    "name": "Leodanis Pozo Ramos",
    "image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
    "url": "https://realpython.com/team/lpozoramos/",
    "affiliation": {
      "@type": "Organization",
      "@id": "https://realpython.com/#organization",
      "name": "Real Python",
      "url": "https://realpython.com",
      "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
    }
  },
  "description": "Learn how to work effectively with Python sets. You\u2019ll define set objects, explore supported operations, and understand when sets are the right choice for your code.",
  "hasPart": {
    "@type": "FAQPage",
    "mainEntity": [
      {
        "@type": "Question",
        "name": "What is a set in Python and how does it differ from a list?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "

A set in Python is an unordered collection of unique and hashable elements, unlike a list, which is ordered and can contain duplicate elements.

" } }, { "@type": "Question", "name": "How do you create a set in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

You can create a set using literals that consist of a pair of curly braces {} with a comma-separated series of elements inside, or by using the set() constructor or a set comprehension.

" } }, { "@type": "Question", "name": "What are some common set operations you can perform on Python\u2019s set?", "acceptedAnswer": { "@type": "Answer", "text": "

You can perform operations like union, intersection, difference, and symmetric difference on Python sets.

" } }, { "@type": "Question", "name": "How can you add or remove elements from a set in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

You can add elements to a set using the .add() method and remove elements with the .remove(), .discard(), or .pop() methods.

" } }, { "@type": "Question", "name": "What are some scenarios where using a set is beneficial?", "acceptedAnswer": { "@type": "Answer", "text": "

Using a set is beneficial when you need to store unique items, perform many membership tests, or eliminate duplicates from an iterable.

" } } ] } }

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/UPDATE-Sets-in-Python_Watermarked.29cc4fe84b78.jpg
og:imagehttps://files.realpython.com/media/UPDATE-Sets-in-Python_Watermarked.29cc4fe84b78.jpg
twitter:creator@realpython
og:typearticle

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/python-sets/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/python-sets/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Fpython-sets%2F
Browse Topicshttps://realpython.com/tutorials/all/
Guided Learning Pathshttps://realpython.com/learning-paths/
Basicshttps://realpython.com/search?level=basics
Intermediatehttps://realpython.com/search?level=intermediate
Advancedhttps://realpython.com/search?level=advanced
aihttps://realpython.com/tutorials/ai/
algorithmshttps://realpython.com/tutorials/algorithms/
apihttps://realpython.com/tutorials/api/
best-practiceshttps://realpython.com/tutorials/best-practices/
careerhttps://realpython.com/tutorials/career/
communityhttps://realpython.com/tutorials/community/
databaseshttps://realpython.com/tutorials/databases/
data-sciencehttps://realpython.com/tutorials/data-science/
data-structureshttps://realpython.com/tutorials/data-structures/
data-vizhttps://realpython.com/tutorials/data-viz/
devopshttps://realpython.com/tutorials/devops/
djangohttps://realpython.com/tutorials/django/
dockerhttps://realpython.com/tutorials/docker/
editorshttps://realpython.com/tutorials/editors/
flaskhttps://realpython.com/tutorials/flask/
front-endhttps://realpython.com/tutorials/front-end/
gamedevhttps://realpython.com/tutorials/gamedev/
guihttps://realpython.com/tutorials/gui/
machine-learninghttps://realpython.com/tutorials/machine-learning/
newshttps://realpython.com/tutorials/news/
numpyhttps://realpython.com/tutorials/numpy/
projectshttps://realpython.com/tutorials/projects/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
testinghttps://realpython.com/tutorials/testing/
toolshttps://realpython.com/tutorials/tools/
web-devhttps://realpython.com/tutorials/web-dev/
web-scrapinghttps://realpython.com/tutorials/web-scraping/
Table of Contentshttps://realpython.com/python-sets/#toc
Getting Started With Python’s set Data Typehttps://realpython.com/python-sets/#getting-started-with-pythons-set-data-type
Building Sets in Pythonhttps://realpython.com/python-sets/#building-sets-in-python
Creating Sets Through Literalshttps://realpython.com/python-sets/#creating-sets-through-literals
Using the set() Constructorhttps://realpython.com/python-sets/#using-the-set-constructor
Using Set Comprehensionshttps://realpython.com/python-sets/#using-set-comprehensions
Performing Common Set Operationshttps://realpython.com/python-sets/#performing-common-set-operations
Unionhttps://realpython.com/python-sets/#union
Intersectionhttps://realpython.com/python-sets/#intersection
Differencehttps://realpython.com/python-sets/#difference
Symmetric Differencehttps://realpython.com/python-sets/#symmetric-difference
Using Augmented Set Operationshttps://realpython.com/python-sets/#using-augmented-set-operations
Augmented Unionhttps://realpython.com/python-sets/#augmented-union
Augmented Intersectionhttps://realpython.com/python-sets/#augmented-intersection
Augmented Differencehttps://realpython.com/python-sets/#augmented-difference
Augmented Symmetric Differencehttps://realpython.com/python-sets/#augmented-symmetric-difference
Comparing Setshttps://realpython.com/python-sets/#comparing-sets
Subsetshttps://realpython.com/python-sets/#subsets
Proper Subsetshttps://realpython.com/python-sets/#proper-subsets
Supersetshttps://realpython.com/python-sets/#supersets
Proper Supersetshttps://realpython.com/python-sets/#proper-supersets
Disjoint Setshttps://realpython.com/python-sets/#disjoint-sets
Using Other Set Methodshttps://realpython.com/python-sets/#using-other-set-methods
Adding an Element With .add()https://realpython.com/python-sets/#adding-an-element-with-add
Removing an Existing Element With .remove()https://realpython.com/python-sets/#removing-an-existing-element-with-remove
Deleting an Existing or Missing Element With .discard()https://realpython.com/python-sets/#deleting-an-existing-or-missing-element-with-discard
Removing and Returning an Element With .pop()https://realpython.com/python-sets/#removing-and-returning-an-element-with-pop
Removing All Elements With .clear()https://realpython.com/python-sets/#removing-all-elements-with-clear
Creating Shallow Copies of Sets With .copy()https://realpython.com/python-sets/#creating-shallow-copies-of-sets-with-copy
Traversing Setshttps://realpython.com/python-sets/#traversing-sets
Accessing and Modifying Elements in a Loophttps://realpython.com/python-sets/#accessing-and-modifying-elements-in-a-loop
Processing and Removing Elements in a Loophttps://realpython.com/python-sets/#processing-and-removing-elements-in-a-loop
Iterating Through a Sorted Sethttps://realpython.com/python-sets/#iterating-through-a-sorted-set
Exploring Other Set Capabilitieshttps://realpython.com/python-sets/#exploring-other-set-capabilities
Finding the Number of Elements With len()https://realpython.com/python-sets/#finding-the-number-of-elements-with-len
Running Membership Tests on Setshttps://realpython.com/python-sets/#running-membership-tests-on-sets
Conclusionhttps://realpython.com/python-sets/#conclusion
Frequently Asked Questionshttps://realpython.com/python-sets/#frequently-asked-questions
https://realpython.com/feedback/survey/article/python-sets/liked/?from=article-sidebar
https://realpython.com/feedback/survey/article/python-sets/disliked/?from=article-sidebar
Using Sets in Pythonhttps://realpython.com/courses/sets-python/
Leodanis Pozo Ramoshttps://realpython.com/python-sets/#author
https://realpython.com/python-sets/#reader-comments
basicshttps://realpython.com/tutorials/basics/
pythonhttps://realpython.com/tutorials/python/
Getting Started With Python’s set Data Typehttps://realpython.com/python-sets/#getting-started-with-pythons-set-data-type
Building Sets in Pythonhttps://realpython.com/python-sets/#building-sets-in-python
Creating Sets Through Literalshttps://realpython.com/python-sets/#creating-sets-through-literals
Using the set() Constructorhttps://realpython.com/python-sets/#using-the-set-constructor
Using Set Comprehensionshttps://realpython.com/python-sets/#using-set-comprehensions
Performing Common Set Operationshttps://realpython.com/python-sets/#performing-common-set-operations
Unionhttps://realpython.com/python-sets/#union
Intersectionhttps://realpython.com/python-sets/#intersection
Differencehttps://realpython.com/python-sets/#difference
Symmetric Differencehttps://realpython.com/python-sets/#symmetric-difference
Using Augmented Set Operationshttps://realpython.com/python-sets/#using-augmented-set-operations
Augmented Unionhttps://realpython.com/python-sets/#augmented-union
Augmented Intersectionhttps://realpython.com/python-sets/#augmented-intersection
Augmented Differencehttps://realpython.com/python-sets/#augmented-difference
Augmented Symmetric Differencehttps://realpython.com/python-sets/#augmented-symmetric-difference
Comparing Setshttps://realpython.com/python-sets/#comparing-sets
Subsetshttps://realpython.com/python-sets/#subsets
Proper Subsetshttps://realpython.com/python-sets/#proper-subsets
Supersetshttps://realpython.com/python-sets/#supersets
Proper Supersetshttps://realpython.com/python-sets/#proper-supersets
Disjoint Setshttps://realpython.com/python-sets/#disjoint-sets
Using Other Set Methodshttps://realpython.com/python-sets/#using-other-set-methods
Adding an Element With .add()https://realpython.com/python-sets/#adding-an-element-with-add
Removing an Existing Element With .remove()https://realpython.com/python-sets/#removing-an-existing-element-with-remove
Deleting an Existing or Missing Element With .discard()https://realpython.com/python-sets/#deleting-an-existing-or-missing-element-with-discard
Removing and Returning an Element With .pop()https://realpython.com/python-sets/#removing-and-returning-an-element-with-pop
Removing All Elements With .clear()https://realpython.com/python-sets/#removing-all-elements-with-clear
Creating Shallow Copies of Sets With .copy()https://realpython.com/python-sets/#creating-shallow-copies-of-sets-with-copy
Traversing Setshttps://realpython.com/python-sets/#traversing-sets
Accessing and Modifying Elements in a Loophttps://realpython.com/python-sets/#accessing-and-modifying-elements-in-a-loop
Processing and Removing Elements in a Loophttps://realpython.com/python-sets/#processing-and-removing-elements-in-a-loop
Iterating Through a Sorted Sethttps://realpython.com/python-sets/#iterating-through-a-sorted-set
Exploring Other Set Capabilitieshttps://realpython.com/python-sets/#exploring-other-set-capabilities
Finding the Number of Elements With len()https://realpython.com/python-sets/#finding-the-number-of-elements-with-len
Running Membership Tests on Setshttps://realpython.com/python-sets/#running-membership-tests-on-sets
Conclusionhttps://realpython.com/python-sets/#conclusion
Frequently Asked Questionshttps://realpython.com/python-sets/#frequently-asked-questions
Remove adshttps://realpython.com/account/join/
Using Sets in Pythonhttps://realpython.com/courses/sets-python/
https://files.realpython.com/media/venn-diagram.d628e9c47300.png
Click here to download the free sample code https://realpython.com/bonus/python-sets-code/
https://realpython.com/quizzes/python-sets/
Python Setshttps://realpython.com/quizzes/python-sets/
https://realpython.com/python-sets/#getting-started-with-pythons-set-data-type
mutablehttps://realpython.com/python-mutable-vs-immutable-types/
hashablehttps://realpython.com/ref/glossary/hashable/
hash valuehttps://realpython.com/ref/builtin-functions/hash/
iterablehttps://realpython.com/python-iterators-iterables/
listhttps://realpython.com/python-list/
tuplehttps://realpython.com/python-tuple/
hash tableshttps://realpython.com/python-hash-table/
in and not in operatorshttps://realpython.com/python-in-operator/
set operationshttps://en.wikipedia.org/wiki/Set_(abstract_data_type)#Operations
unionhttps://realpython.com/python-sets/#union
intersectionhttps://realpython.com/python-sets/#intersection
differencehttps://realpython.com/python-sets/#difference
symmetric differencehttps://realpython.com/python-sets/#symmetric-difference
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#building-sets-in-python
literalshttps://realpython.com/ref/glossary/literal/
set()https://docs.python.org/3/library/stdtypes.html#set
set comprehensionhttps://realpython.com/python-set-comprehension/
https://realpython.com/python-sets/#creating-sets-through-literals
unpackhttps://realpython.com/python-tuple/#packing-and-unpacking-tuples
RGBhttps://en.wikipedia.org/wiki/RGB_color_model
numbershttps://realpython.com/python-numbers/
Nonehttps://realpython.com/null-in-python/
data typeshttps://realpython.com/ref/builtin-types/
dictionarieshttps://realpython.com/python-dicts/
bytearrayhttps://realpython.com/python-bytearray/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#using-the-set-constructor
constructorhttps://realpython.com/python-class-constructor/
stringshttps://realpython.com/python-strings/
https://realpython.com/python-sets/#using-set-comprehensions
list comprehensionshttps://realpython.com/list-comprehension-python/
listhttps://realpython.com/python-list/
tuplehttps://realpython.com/python-tuple/
sethttps://realpython.com/python-sets/
generatorhttps://realpython.com/introduction-to-python-generators/
filterhttps://realpython.com/python-set-comprehension/#filtering-items-from-sets
Python Set Comprehensions: How and When to Use Themhttps://realpython.com/python-set-comprehension/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#performing-common-set-operations
operationshttps://en.wikipedia.org/wiki/Set_(mathematics)#Basic_operations
https://realpython.com/python-sets/#union
.union()https://docs.python.org/3/library/stdtypes.html#frozenset.union
https://files.realpython.com/media/set-union.69c7d74dd09f.png
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#intersection
.intersection()https://docs.python.org/3/library/stdtypes.html#frozenset.intersection
https://files.realpython.com/media/set-intersection.787a3db7e6b6.png
https://realpython.com/python-sets/#difference
.difference()https://docs.python.org/3/library/stdtypes.html#frozenset.difference
https://files.realpython.com/media/set-difference.c25b4e25419a.png
https://files.realpython.com/media/t.b37d6f78f99a.png
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#symmetric-difference
.symmetric_difference()https://docs.python.org/3/library/stdtypes.html#frozenset.symmetric_difference
https://files.realpython.com/media/set-symmetric-difference.cf0de76c1c6c.png
exclusive ORhttps://en.wikipedia.org/wiki/Exclusive_or
TypeErrorhttps://realpython.com/python-built-in-exceptions/#typeerror
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#using-augmented-set-operations
augmented variationshttps://realpython.com/python-assignment-operator/#augmented-assignment-operators-in-python
in placehttps://en.wikipedia.org/wiki/In-place_algorithm
frozensethttps://docs.python.org/3/library/stdtypes.html#frozenset
https://realpython.com/python-sets/#augmented-union
.update()https://docs.python.org/3/library/stdtypes.html#frozenset.update
id() functionhttps://realpython.com/python-built-in-functions/#knowing-an-objects-identity-id
https://realpython.com/python-sets/#augmented-intersection
.intersection_update()https://docs.python.org/3/library/stdtypes.html#frozenset.intersection_update
https://realpython.com/python-sets/#augmented-difference
.difference_update()https://docs.python.org/3/library/stdtypes.html#frozenset.difference_update
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#augmented-symmetric-difference
.symmetric_difference_update()https://docs.python.org/3/library/stdtypes.html#frozenset.symmetric_difference_update
https://realpython.com/python-sets/#comparing-sets
Booleanhttps://realpython.com/python-boolean/
https://realpython.com/python-sets/#subsets
.issubset()https://docs.python.org/3/library/stdtypes.html#frozenset.issubset
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#proper-subsets
https://realpython.com/python-sets/#supersets
.issuperset()https://docs.python.org/3/library/stdtypes.html#frozenset.issuperset
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#proper-supersets
https://realpython.com/python-sets/#disjoint-sets
.isdisjoint()https://docs.python.org/3/library/stdtypes.html#frozenset.isdisjoint
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-sets/#using-other-set-methods
https://realpython.com/python-sets/#adding-an-element-with-add
.add()https://docs.python.org/3/library/stdtypes.html#frozenset.add
https://realpython.com/python-sets/#removing-an-existing-element-with-remove
.remove()https://docs.python.org/3/library/stdtypes.html#frozenset.remove
KeyErrorhttps://realpython.com/python-built-in-exceptions/#keyerror
https://realpython.com/python-sets/#deleting-an-existing-or-missing-element-with-discard
.discard()https://docs.python.org/3/library/stdtypes.html#frozenset.discard
raise an exceptionhttps://realpython.com/python-raise-exception/
https://realpython.com/python-sets/#removing-and-returning-an-element-with-pop
.pop()https://docs.python.org/3/library/stdtypes.html#frozenset.pop
variablehttps://realpython.com/python-variables/
https://realpython.com/python-sets/#removing-all-elements-with-clear
.clear()https://docs.python.org/3/library/stdtypes.html#frozenset.clear
https://realpython.com/python-sets/#creating-shallow-copies-of-sets-with-copy
.copy()https://docs.python.org/3/library/stdtypes.html#frozenset.copy
shallow copyhttps://realpython.com/python-copy/#understanding-shallow-and-deep-copying
https://realpython.com/python-sets/#traversing-sets
for loophttps://realpython.com/python-for-loop/
while loophttps://realpython.com/python-while-loop/
https://realpython.com/python-sets/#accessing-and-modifying-elements-in-a-loop
https://realpython.com/python-sets/#processing-and-removing-elements-in-a-loop
while loophttps://realpython.com/python-while-loop/
https://realpython.com/python-sets/#iterating-through-a-sorted-set
sorted()https://realpython.com/python-sort/
lambdahttps://realpython.com/python-lambda/
https://realpython.com/python-sets/#exploring-other-set-capabilities
Using the len() Function in Pythonhttps://realpython.com/len-python-function/
Python’s in and not in Operators: Check for Membershiphttps://realpython.com/python-in-operator/
https://realpython.com/python-sets/#finding-the-number-of-elements-with-len
https://realpython.com/python-sets/#running-membership-tests-on-sets
scripthttps://realpython.com/run-python-scripts/
https://realpython.com/python-sets/#conclusion
Click here to download the free sample code https://realpython.com/bonus/python-sets-code/
https://realpython.com/python-sets/#frequently-asked-questions
https://realpython.com/quizzes/python-sets/
Python Setshttps://realpython.com/quizzes/python-sets/
https://realpython.com/feedback/survey/article/python-sets/liked/?from=article-footer
https://realpython.com/feedback/survey/article/python-sets/disliked/?from=article-footer
Using Sets in Pythonhttps://realpython.com/courses/sets-python/
https://realpython.com/team/lpozoramos/
» More about Leodanishttps://realpython.com/team/lpozoramos/
https://realpython.com/team/asantos/
Aldrenhttps://realpython.com/team/asantos/
https://realpython.com/team/bweleschuk/
Brendahttps://realpython.com/team/bweleschuk/
https://realpython.com/team/bzaczynski/
Bartoszhttps://realpython.com/team/bzaczynski/
https://realpython.com/team/damos/
Davidhttps://realpython.com/team/damos/
https://realpython.com/team/jjablonski/
Joannahttps://realpython.com/team/jjablonski/
https://realpython.com/team/jsturtz/
Johnhttps://realpython.com/team/jsturtz/
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-sets
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-sets
https://realpython.com/feedback/survey/article/python-sets/liked/?from=article-comments
https://realpython.com/feedback/survey/article/python-sets/disliked/?from=article-comments
LinkedInhttps://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fpython-sets%2F
Twitterhttps://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20Sets%20in%20Python&url=https%3A%2F%2Frealpython.com%2Fpython-sets%2F
Blueskyhttps://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20Sets%20in%20Python%20https%3A%2F%2Frealpython.com%2Fpython-sets%2F
Facebookhttps://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fpython-sets%2F
Get tips for asking good questionshttps://realpython.com/python-beginner-tips/#tip-9-ask-good-questions
get answers to common questions in our support portalhttps://support.realpython.com
Real Python Community Chathttps://realpython.com/community/
“Office Hours” Live Q&A Sessionhttps://realpython.com/office-hours/
basicshttps://realpython.com/tutorials/basics/
pythonhttps://realpython.com/tutorials/python/
Using Sets in Pythonhttps://realpython.com/courses/sets-python/
Dictionaries in Pythonhttps://realpython.com/python-dicts/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-sets
Python's tuple Data Type: A Deep Dive With Exampleshttps://realpython.com/python-tuple/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-sets
Iterators and Iterables in Python: Run Efficient Iterationshttps://realpython.com/python-iterators-iterables/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-sets
Python Set Comprehensions: How and When to Use Themhttps://realpython.com/python-set-comprehension/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-sets
How to Use Generators and yield in Pythonhttps://realpython.com/introduction-to-python-generators/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-sets
https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-sets%2F
Continue »https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-sets%2F
Sign-Inhttps://realpython.com/account/login/?next=/python-sets/
Start Herehttps://realpython.com/start-here/
Learning Resourceshttps://realpython.com/search
Code Mentorhttps://realpython.com/mentor/
Python Referencehttps://realpython.com/ref/
Python Cheat Sheethttps://realpython.com/cheatsheets/python/
Support Centerhttps://support.realpython.com/
Learning Pathshttps://realpython.com/learning-paths/
Quizzes & Exerciseshttps://realpython.com/quizzes/
Browse Topicshttps://realpython.com/tutorials/all/
Live Courseshttps://realpython.com/live/
Bookshttps://realpython.com/books/
Podcasthttps://realpython.com/podcasts/rpp/
Newsletterhttps://realpython.com/newsletter/
Community Chathttps://realpython.com/community/
Office Hourshttps://realpython.com/office-hours/
Learner Storieshttps://realpython.com/learner-stories/
Plans & Pricinghttps://realpython.com/account/join/
Team Planshttps://realpython.com/account/join-team/
For Businesshttps://realpython.com/account/join-team/inquiry/
For Schoolshttps://realpython.com/account/join-team/education-inquiry/
Reviewshttps://realpython.com/learner-stories/
About Ushttps://realpython.com/about/
Teamhttps://realpython.com/team/
Mission & Valueshttps://realpython.com/mission/
Editorial Guidelineshttps://realpython.com/editorial-guidelines/
Sponsorshipshttps://realpython.com/sponsorships/
Careershttps://realpython.workable.com
Press Kithttps://realpython.com/media-kit/
Merchhttps://realpython.com/merch
https://www.youtube.com/realpython
https://x.com/realpython
https://www.linkedin.com/company/realpython-com
https://www.facebook.com/LearnRealPython
https://github.com/realpython/
Privacy Policyhttps://realpython.com/privacy-policy/
Terms of Usehttps://realpython.com/terms/
Securityhttps://realpython.com/security/
Contacthttps://realpython.com/contact/
https://realpython.com/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.