Someone commented on one of my answers that the code no longer works. They said “I think a major point is how to retrieve those values (0:2 and 3: in this case). What you replace the elements 4 and 3? Your code no longer works and you need to change it...”: https://stackoverflow.com/a/43283924/3474956
I am not sure what they mean. The code still works with Python 3.7. I think my post answers the question. The desired entries in the list are removed when my code is run. Am I missing something? Do I need to change that answer?
s[0:2] + s[3:]
works (as woulds[:2] + s[3:]
) you leave out how to determine the index (here2
) to skip, or deal with the possibility that the value might appear at more than one index. The question was how to delete by value, not index.