Nov-07-2020, 04:24 PM
There are many issues with this code. The problem that you describe comes from modifying the list while iterating upon it. Let us simplify things by supposing that the list is
['foo bar', 'baz qux', 'login quux', 'static corge', 'grault garply']When i=2, the 'login quux' is found and removed from the list. On the next iteration, one has i=3 but 'static corge' is never found because its index is now 2 instead of 3, so your algorithm could work if you started from the end of the list with
for i in range(len(vdescription_tokens) - 1, -1, -1): ...Another obvious issue is that the code repeats itself a lot and it needs to be refactored to avoid this litany of if, elif, elif...