@Rushy's answer is great and probably what I would recommend.
That said, if you want to remove consecutive duplicates and you want to do it in-place (by modifying the list rather than creating a second one), one common technique is to work your way backwards through the list:
def remove_consecutive_duplicates(lst):
for i in range(len(lst) - 1, 1, -1):
if lst[i] == lst[i-1]:
lst.pop(i)
x = ['a', 'b', 'b', 'c', 'd', 'd', 'd', 'e', 'f', 'f']
remove_consecutive_duplicates(x)
print(x) # ['a', 'b', 'c', 'd', 'e', 'f']
By starting at the end of the list and moving backwards, you avoid the problem of running off the end of the list because you've shortened it.
E.g. if you start with 'aabc' and move forwards, you'll use the indexes 0, 1, 2, and 3.
0
|
aabc
(Found a duplicate, so remove that element.)
1
|
abc
2
|
abc
3
|
abc <-- Error! You ran off the end of the list.
Going backwards, you'll use the indexes 3, 2, 1, and 0:
3
|
aabc
2
|
aabc
1
|
aabc
(Found a duplicate so remove that element.)
0
|
abc <-- No problem here!