[Solved] Remove some duplicates from list in python
this is where itertools.groupby may come in handy: from itertools import groupby a = [“a”, “a”, “b”, “b”, “a”, “a”, “c”, “c”] res = [key for key, _group in groupby(a)] print(res) # [‘a’, ‘b’, ‘a’, ‘c’] this is a version where you could ‘scale’ down the unique keys (but are guaranteed to have at leas … Read more