[Solved] Is there a way of deleting specific adjacent duplicates in a list on python 3? [closed]

[ad_1]

Sure:

excludes = ['Q']
prev = None
out = []

for item in my_list:
  if item != prev or item in excludes:
    out += item
  prev = item

print(out)

2

[ad_2]

solved Is there a way of deleting specific adjacent duplicates in a list on python 3? [closed]