The join method
The join method merges the elements of a list into a string with the specified separator (space, comma, etc.).
Syntax
'separator'.join(list of lines)
Example
Let's merge the list elements into a string:
lst = ['ab', 'cd', 'ef']
txt = ' '.join(lst)
print(txt)
Result of code execution:
'ab cd ef'
Example
Now let's use a comma as a separator:
lst = ['ab', 'cd', 'ef']
txt = ','.join(lst)
print(txt)
Result of code execution:
'ab,cd,ef'