CodePudding user response:
Because you have a remove operation while traversing lst in a for loop, the elements in lst are decreasing.
Based on the existing code, you can try to modify for a in lst to for a in lst.copy()
CodePudding user response:
Because after first iteration "a" position is 0 and it take 1st position item i.e "d".
