Python3 join() Method
Description
The Python join() method joins the elements of a sequence with a specified character to generate a new string.
Syntax
Syntax of the join() method:
str.join(sequence)
Parameters
- sequence -- the sequence of elements to be joined.
Return Value
Returns the new string generated by joining the elements of the sequence with the specified character.
Example
The following example shows how to use join():
Example
#!/usr/bin/python3
s1
=
"-"
s2
=
""
seq
=
(
"r"
,
"u"
,
"n"
,
"o"
,
"o"
,
"b"
)
String sequence
(
s1.
join
(
seq
)
)
(
s2.
join
(
seq
)
)
The output of the above example is:
r-u-n-o-o-b
runoob
Python3 Strings