Pretty close. Something like this:
1. Depends if you work top down of bottom up
2. Select layers
At that point you can inspect the contents of delete_layers to make sure they are the ones
3. Delete them
Coded in slo-mo (so to speak) for better readability, a tattooed Python coder would have done a one-liner
1. Depends if you work top down of bottom up
Code:
layers=image.layers[:] # Make a copy of the list
layers.reverse() # if working bottom up
2. Select layers
Code:
keep=3
delete=2
stride=keep+delete
deleted_layers=[layer for i in range(keep,len(layers),stride) for layer in layers[i:i+delete]]
At that point you can inspect the contents of delete_layers to make sure they are the ones
3. Delete them
Code:
for l in deleted_layers:
image.remove_layer(l)
Coded in slo-mo (so to speak) for better readability, a tattooed Python coder would have done a one-liner