Thursday, March 8, 2018

String join() Method


String join() Method in Python 3


The join() method returns a string in which the string elements of sequence have been joined by str separator.

Syntax
str.join(sequence)

Parameters
          sequence - This is a sequence of the elements to be joined.
Return Value
This method returns a string, which is the concatenation of the strings in the sequence seq. The separator between elements is the string providing this method.

Example
#!/usr/bin/python3
s = "-"
seq = ("a", "b", "c") # This is sequence of strings.
print (s.join( seq ))

  
Result
a-b-c