Immutable Data Types7:45 with AJ Tran
Sets can only contain immutable data types. Immutable means the data cannot be changed after it is created, such as strings, integers, and floats.
What are some immutable types?
Can I put a tuple in a set?
Tuples are also an immutable type! A tuple can be in a set if and only if the elements of the tuple are also immutable. Making a set with a tuple that contains mutable types will raise a
Why does the TypeError say
Unhashable means Mutable. Our TypeErrors were telling us that lists, dictionaries, and sets are mutable.
Hashable means Immutable. A hashable type can be a member of a set or a dictionary key. Hashable objects are the reason why sets and dictionaries are so fast at "lookup" operations.
You need to sign up for Treehouse in order to download course files.Sign up