I want to get a sublist (not necessarily contigous) with all of the repeated elements from some list. But to clarify things, I don't want just the repeated items, I want them in the same order and quantity they appear in the list. That is:
Input sample:
A = [1, 2, 2, 2, 3, 4, 8, 8, 9, 9]
Expected output:
A = [2, 2, 2, 8, 8, 8, 9, 9]
Does anyone know a good way of doing this?