I have two lists like:
x = ['A','A','A','B','B','C','C','C','D']
list_date = ['0101','0102','0103','0104','0105','0106','0107','0108','0109']
I wanna remove the duplicates elements of the list, and it can be fulfilled by the answer in Removing elements that have consecutive duplicates
However, the ouput I expect is like
['A','B','C','D']
['0101','0104','0106','0109']
That is
For x, I wanna remove the duplicate elements.
For list_date, I wanna remain the dates based on the remaining elements in x.
Do you have any way to implement this?
2020-06-14 updated:
Thank you for the answers!
My data also has the case
y = ['A','A','A','B','B','C','C','C','D','A','A','C','C','B','B','B']
list_date = ['0101','0102','0103','0104','0105','0106','0107','0108','0109','0110','0111','0112','0113','0114','0115','0116']
The output should be
['A','B','C','D','A','C','B']
['0101','0104','0106','0109','0110','0112','0114']
How should I process the list like this?