Answers for "python join multiple strings ignore none and empty string"

0

python join list ignore none and empty string

>>> strings = ['foo','','bar','moo']
>>> ' '.join(filter(None, strings))
'foo bar moo'
Posted by: Guest on November-07-2020
0

python join multiple strings ignore none and empty string

# Concatenates string variables a and b with ' - ' or Coalesces them if one is None
'-'.join([x for x in (a,b) if x])
Posted by: Guest on December-14-2020

Code answers related to "python join multiple strings ignore none and empty string"

Python Answers by Framework

Browse Popular Code Answers by Language