Possible Duplicate:
Flatten (an irregular) list of lists in Python
I have a list in python like
l=[1,2,[3,4,5],[[4,2,4],[4,7,8]]]
I want using a set to get all unique values, but this fails
set(l)
TypeError: unhashable type: 'list'
So anybody help please? Want to use set with list of list of list etc etc THX
You’ll need to ‘unwind’, or flatten the nested structure before you can put this in a set. You can use a generator for that to keep this efficient for large lists:
then use that generator on your list
lto create a set: