lst = [1, 2, 3, 2, 2]s = set()print(list([(s.add(x) or x) for x in lst if x not in s]))
Standard input is empty
[1, 2, 3]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!