I'm writing a piece of code that should take a list with several numbers (like this for example: [2,3,5,6,6]
) and create a new list, removing all duplicates (to end up with [2,3,5,6]
).
The code I have is this:
first_list = [2,3,5,6,6]
second_list = []
second_list = [x for x in first_list if x not in second_list]
However, it makes second_list
equal to first_list
, and I don't understand why. How can I make it do what I explained above?