carolle N'guessan
PRO
2 days ago
Carollecountry asked

In the lesson on sets, it was stated that sets are immutable. So why does the summary on data types state that sets are mutable?

Anuj Shrestha
Expert
yesterday
Anuj Shrestha answered

Hi! Good observation but the summary is actually correct, and the confusion usually comes from how the word immutable is used.

In Python, a set itself is mutable. This means you can add or remove items from a set after it’s created, which is why the table correctly marks Set → Mutable: Yes.

immutable are the elements inside a set. Every item stored in a set must be immutable (for example: numbers, strings, or tuples). This is why you cannot put lists or other sets inside a set.

So to summarize:

  • Set (container): Mutable ✅

  • Elements inside a set: Must be immutable ✅

If a lesson mentioned that “sets are immutable,” it was likely referring to the elements of a set, not the set itself.

Hope this clears your confusion. Feel free to ask again. I will take a look at the previous lesson too to make sure we are clarifying it properly. Thanks for asking.

Python
This question was asked as part of the Learn Python Basics course.