4 ms·
Python list comprehensions and the with keyword
- captaincrowbar 12y agoYou 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