How can I select a specific number in a list with duplicates without removing the previous same values?

  python-3.x

I have the following list in python3:
a = [1, 1, 1, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 4, 4, 4, 3, 3, 3, 3].
I want to have something like this as an output:
b = [1, 2, 3, 1, 2, 4, 3].
How can I do that? I have tried a = set(a) and other methods for getting rid of duplicates. But they remove all duplicates.

Source: Python-3x Questions

LEAVE A COMMENT