Python join() Method
Description
The Python join() method is used to join elements in a sequence with a specified character to generate a new string.
Syntax
Syntax of join() method:
str.join(sequence)
Parameters
- sequence -- The sequence of elements to be joined.
Return Value
Returns a new string generated by joining the elements in the sequence with the specified character.
Examples
The following examples demonstrate 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 as follows:
a-b-c
Other Extensions
Python Strings