xxxxxxxxxx
numList = ['1', '2', '3', '4']
separator = ', '
print(separator.join(numList))
xxxxxxxxxx
# use of join function to join list
# elements without any separator.
# Joining with empty separator
list1 = ['g','e','e','k', 's']
print("".join(list1))
#Output:
geeks
xxxxxxxxxx
test_string = " ".join(['Test', 'the', 'join()', 'method'])
print(test_string)
[output]
'Test the join() method'
xxxxxxxxxx
>>> ''.join(['A', 'B', 'C'])
'ABC'
>>> ''.join({'A': 0, 'B': 0, 'C': 0}) # note that dicts are unordered
'ACB'
>>> '-'.join(['A', 'B', 'C']) # '-' string is the seprator
'A-B-C'
xxxxxxxxxx
w=["as","3e","1"]
a='vf'.join(w)
// w neccessarily needs to be a list of strings.
print(a)
//displays string asvf3evf1