Definition
The join() method takes all items in an iterable and joins them into one string. A string must be specified as the separator.
Syntax
string.join(iterable)
Parameters
Parameter | Description |
---|---|
iterable | Required. Any iterable object where all the returned values are strings |
Examples:
fruits = ("apple", "banana", "orange")
result = ", ".join(fruits)
print(result)
# another example
car = {"name": "Ford", "model": 1987}
mySeparator = " *** "
result = mySeparator.join(car)
print(result)