Python String join() Method
The join()
method returns a string, which is the concatenation of the string (on which it is called) with the string elements of the specified iterable as an argument.
Syntax:
str.join(iterable)
Parameters:
iterable: (Required) An iterable object such as list, tuple, string, set, dict.
Return Value:
Returns a string.
The following example demonstrates the join()
method.
emp = {'Steve': 1, 'Bill': 2, 'Ravi': 3 }
print('>-'.join(emp))
emp = {1:'Steve', 2:'Bill', 3:'Ravi' } # raise an error
print('>-'.join(emp))
Steve>-Bill>-Ravi TypeError: sequence item 0: expected str instance, int found