Kent Johnson wrote:
> The solution is to turn the list into something immutable. One way would
> be to convert the lists to tuples:
> n1 = list(set(tuple(i) for i in n))
>
> This gives you a list of tuples, if you need a list of lists you will
> have to convert back which you can do with a list
Switanek, Nick wrote:
> I'd like to remove redundant items from a list, and have read that using
> set() is an effective way to do it. But I often get the following error,
> and I'd be glad for your help understanding what's wrong.
>
type(n)# This is a list of lists of strings
>
I'd like to remove redundant items from a list, and have read that using
set() is an effective way to do it. But I often get the following error,
and I'd be glad for your help understanding what's wrong.
>>> z = ['test','test',1,2,1]
>>> set(z)
set(['test', 1, 2])
>>> list(set(z))# Works a