concatenate all elements of a list python code example
Example 1: combine all items in a list python
>> a = ['a', 'b', 'c']
>> res = "".join(a)
>> print(res)
abc
Example 2: python join items in list
l = ['aaa', 'bbb', 'ccc']
s = ''.join(l)
print(s)
# aaabbbccc
s = ','.join(l)
print(s)
# aaa,bbb,ccc
s = '-'.join(l)
print(s)
# aaa-bbb-ccc
s = '\n'.join(l)
print(s)
# aaa
# bbb
# ccc
Example 3: how to concate a string to all elements in a list in python
[s + mystring for s in mylist]