Aug-16-2020, 12:14 PM
As stated in docs,
Quote:A set object is an unordered collection of distinct hashable objects.
...
There are currently two built-in set types, set and frozenset. The set type is mutable — the contents can be changed using methods like add() and remove(). Since it is mutable, it has no hash value and cannot be used as either a dictionary key or as an element of another set. The frozenset type is immutable and hashable — its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set.
>>> spam = {1, 2} >>> type(spam) <class 'set'> >>> eggs = {spam} Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'set' >>> spam = frozenset(spam) >>> type(spam) <class 'frozenset'> >>> eggs = {spam} >>> type(eggs) <class 'set'>
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs