Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python join() method

Python join() method

Python Strings Python Strings


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

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

print

symbol

.

join

(

seq

)

;

The output of the above example is:


a-b-c

Python Strings Python Strings