R
Robert Latest
Hello,
From a list of strings I want to delete all empty ones. This works:
while '' in keywords: keywords.remove('')
However, to a long-term C programmer this looks like an awkward way of
accomplishing a simple goal, because the list will have to be re-evaluated
in each iteration. Is there a way to just walk the list once and throw out
unwanted elements as one goes along?
I started programming back when such little things were real performance
issues, so I have some sort of cringe reflex when something looks
inefficient.
robert
From a list of strings I want to delete all empty ones. This works:
while '' in keywords: keywords.remove('')
However, to a long-term C programmer this looks like an awkward way of
accomplishing a simple goal, because the list will have to be re-evaluated
in each iteration. Is there a way to just walk the list once and throw out
unwanted elements as one goes along?
I started programming back when such little things were real performance
issues, so I have some sort of cringe reflex when something looks
inefficient.
robert