Python 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 (Python 2.0+)
#!/usr/bin/python
-- coding: UTF-8 --
symbol
=
"
"
;
seq
=
(
"
a
"
,
"
b
"
,
"
c
"
)
;
String sequence
symbol
.
join
(
seq
)
;
The output of the above example is:
a-b-c
Python Strings