How to join multiple strings with none values in Python

1 Answer

0 votes
str1 = 'python'
str2 = None
str3 = 'java'
str4 = None

result = ' '.join(filter(None, [str1, str2, str3, str4]))

print(result) 





'''
run:

python java

'''

 



answered Jun 16, 2022 by avibootz

Related questions

1 answer 225 views
1 answer 191 views
1 answer 186 views
1 answer 234 views
1 answer 215 views
1 answer 196 views
1 answer 219 views
...