2

How do I remove duplicate lists from a list in Python manually?

Let's say I have a list of lists:

lsts = [['bob', 'ryan'], ['jess', 'kim'], ['bob', 'ryan'], ['ryan', 'bob'], ['kim', 'jess'], 
       ['oliver', 'lim']]

The order shouldn't matter here as I want to remove duplicate lists that contain same elements.

I want to return this:

ret_lsts = [['bob', 'ryan'], ['jess', 'kim'], ['oliver', 'lim']]

Is there a simple manual way to achieve this in Python?

Dew Man7
  • 33
  • 5
  • 1
    `list(map(list, set(map(frozenset, lsts))))` works as long as you don't care about the ordering of either the sublists or the top level list. – Samwise Nov 03 '20 at 17:34

0 Answers0