Source From Here
Question
I want to remove all empty strings from a list of strings in python. Is there any more pythonic way to do this?
How-To
There are many approaches to fit your need:
* Using Built-in Function - filter(function, iterable)
Notes. Python 3 returns an iterator from filter, so should be wrapped in a call to list()
* List Comprehensions
Question
I want to remove all empty strings from a list of strings in python. Is there any more pythonic way to do this?
How-To
There are many approaches to fit your need:
* Using Built-in Function - filter(function, iterable)
Notes. Python 3 returns an iterator from filter, so should be wrapped in a call to list()
* List Comprehensions
沒有留言:
張貼留言