>>> strings = ['foo','','bar','moo']
>>> ' '.join(filter(None, strings))
'foo bar moo'
By using None
in the filter()
call, it removes all falsy elements.
>>> strings = ['foo','','bar','moo']
>>> ' '.join(filter(None, strings))
'foo bar moo'
By using None
in the filter()
call, it removes all falsy elements.