VOOZH about

URL: https://www.geeksforgeeks.org/python/are-sets-mutable-in-python/

⇱ Are Sets Mutable in Python? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Are Sets Mutable in Python?

Last Updated : 23 Jul, 2025

Yes, sets are mutable in Python. This means that you can modify the contents of a set after it has been created. You can add or remove elements from a set but like dictionaries, the elements within a set must be immutable types.

Example of Mutability in Sets

Adding Elements to a Set

You can add elements to a set using add() method:


Output
{1, 2, 3, 4}

What Does It Mean for Sets to Be Mutable?

When we say that sets are mutable, we mean that:

  1. You can add elements to a set after it is created.
  2. You can remove elements from a set.
  3. You can update a set by performing set operations (like union, intersection, etc.).
Comment
Article Tags:
Article Tags: