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 227 views
1 answer 195 views
1 answer 186 views
1 answer 237 views
1 answer 216 views
1 answer 197 views
1 answer 220 views
...