Discover more from Daily Dose of Data Science
List : Tuple :: Set : ?
Dictionaries in Python require their keys to be immutable. As a result, a set cannot be used as keys as it is mutable.
Yet, if you want to use a set, consider declaring it as a frozenset.
It is an immutable set, meaning its elements cannot be changed after it is created. Therefore, they can be safely used as a dictionary’s key.
Share this post on LinkedIn: Post Link.
Thanks for reading Daily Dose of Data Science! Subscribe for free to receive new posts and support my work.
Find the code for my tips here: GitHub.