How to remove duplicate lists in a list of list? [duplicate]

You could use a set:

b_set = set(map(tuple,a))  #need to convert the inner lists to tuples so they are hashable
b = list(map(list,b_set)) #Now convert tuples back into lists (maybe unnecessary?)

Or, if you prefer list comprehensions/generators:

b_set = set(tuple(x) for x in a)
b = [ list(x) for x in b_set ]

Finally, if order is important, you can always sort b:

b.sort(key = lambda x: a.index(x) )

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)