PythonStringjoin

Joins elements of an iterable with the string as separator.

Syntax

sep.join(iterable)

Example

Enter values below to update the example in real time.

words
result
print
Hello
World
Python
nums
words = ["Hello", "World", "Python"]
result = " ".join(words)
print(result)  # Hello World Python

nums = ["1", "2", "3"]
print("-".join(nums))  # 1-2-3