join()
« All String methods
my_str.join()
Returns a string after joining elements of any iterable object using any delimiter.
We will use list, dictionary, tuple, set string in our examples.
my_list=['Alex','Ronald','John']
output='*'.join(my_list)
print(output) # Alex*Ronald*John
my_tuple=('Alex','Ronald','John')
output='#'.join(my_tuple)
print(output) # Alex#Ronald#John
my_set={'Alex','Ronald','John'}
output=' '.join(my_set)
print(output) # Alex Ronald John
my_dict={'a':'Alex','b':'Ronald','c':'John'}
output='%'.join(my_dict)
print(output) # a%b%c ( only keys are present ( not values ))
my_str='plus2net'
output='*'.join(my_str)
print(output) # p*l*u*s*2*n*e*t
« All String methods
This article is written by plus2net.com team.
plus2net.com