The join() method is used to join elements in a sequence with the specified characters to generate a new string.
Example
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
s1 = "-"
s2 = ""
seq = ("a", "b", "c", "d", "e", "f")
print (s1.join( seq ))
print (s2.join( seq ))
Output:
a-b-c-d-e-f
abcdef
Syntax
str.join(sequence)
Parameters
Name | Description |
sequence | The sequence of elements to connect to. |
Return Value
It returns a string, which is the concatenation of the strings in the parameter sequence.