List as an item in a set is giving error

lst=[1,2,5,“hello”,{1,2,3}]

print(lst)

set1={1,2,[2,4]}

print(set1)

list as an item in set gives error

@dk89990

If you instead want to add the entire list as a single element to the set, you can’t because lists aren’t hashable

1 Like

set is a data type which contains only integer as well as floating values so in this set1={1,2,[2,4]} here your inserting list and that is not possible because set is unordered type of collection.