How to join a list of strings and numbers to string in Python

1 Answer

0 votes
lst = [1, 2, 'python', 3, 'java', 'c', 4, 'c++', 7, 9]
 
s = '-'.join(map(str, lst))
 
print(s)
     
     
    
     
'''
run:
 
1-2-python-3-java-c-4-c++-7-9
 
'''

 



answered Jun 16, 2021 by avibootz

Related questions

1 answer 122 views
1 answer 182 views
2 answers 278 views
2 answers 322 views
1 answer 184 views
1 answer 288 views
288 views asked Sep 8, 2018 by avibootz
...