Monday 20 April 2020

Get first non-empty string from a list in python

next(s for s in list_of_string if s)
Edit: py3k proof version as advised by Stephan202 in comments, thanks.

from : https://stackoverflow.com/questions/1138024/get-first-non-empty-string-from-a-list-in-python

No comments:

Post a Comment