3 ms·
You can do this in one line, without calling strip() twice: stripped_words = [w for w in [w.strip() for w in words] if w]
by captaincrowbar 12y ago
You can do this in one line, without calling strip() twice:
stripped_words = [w for w in [w.strip() for w in words] if w]
- damandumpsta 12y agoThat requires two iterations through the list though, which isn't ideal