Python‎ > ‎str‎ > ‎

str.join()


Definition
Return a string which is the concatenation of the strings in the iterable. The separator between elements is S.

Syntax
str.join(iterable) -> str

Parameters
str=string

Examples
 >>> "Python".join("Lake")
'LPythonaPythonkPythone'
>>> "ython".join("P")
'P'
>>> "Python".join("P")
'P'
>>> "python".join("2014")
'2python0python1python4'
>>> "Python".join("Py")
'PPythony'
>>>

Returns are following:
 >>> list=["Python", "Research", "Centre"]
>>> "Lake".join(list)
'PythonLakeResearchLakeCentre'
>>> set={"Pyhton", "Research", "Centre"}
>>> "Lake".join(set)
'ResearchLakePyhtonLakeCentre'
>>> tuple=("Pyhton", "Research", "Centre")
>>> "Lake".join(tuple)
'PyhtonLakeResearchLakeCentre'
>>> list==set
False
>>> set==tuple
False
>>> False==False
True
>>> "Lake".join(tuple)=="Lake".join(set)
False
>>> 'PyhtonLakeResearchLakeCentre'=='ResearchLakePyhtonLakeCentre'
False
>>> 'PythonLakeResearchLakeCentre'=='PythonLakeResearchLakeCentre'
True
>>>

Comments