Merge Tuple to String in Python
You can also merge elements of a tuple into a string using the join
method:
tpl = ('a', 'b', 'c')
txt = '-'.join(tpl)
print(txt) # 'a-b-c'
A tuple is given:
tpl = ('1', '2', '3', '4', '5')
Merge the elements of this tuple into a string with a separator:
'1-2-3-4-5'
A tuple is given:
tpl = ('1', '2', '3', '4', '5')
Merge the elements of this tuple into a string:
'12345'