data_list = [slice(1, 2), slice(3, 4)]
data_set = set(data_list)
Error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[92], line 2
1 data_list = [slice(1, 5), slice(5, 10)]
----> 2 data_set = set(data_list)
TypeError: unhashable type: 'slice'
Reason for the Error:
Here we are trying to convert a list of slices to a set, this is not possible because slices are mutable whereas sets are a hash-based data structure that needs their elements to be immutable.

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!