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


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

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