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 128 views
1 answer 109 views
1 answer 119 views
1 answer 157 views
1 answer 124 views
1 answer 125 views
1 answer 132 views
...