Converting a tuple to a string
Title
Question
Can we convert a tuple to a string like we do for lists?
Python-3.4.3 Sequence-datatypes 03-04 min 0-10 sec
Answers:
STuple = (123, 'xy', 'vinay', 'giet')
Slist = (STuple)
Print("List of element is : ", Slist)
def convertTuple(tup):
str = ' '.join(tup)
return str
Tuple = ('1','2','3')
str = convertTuple(tup)
Print(str)
def convertTuple(tup):
str =' '.join(tup)
return str
Tuple = convertTuple(tup)
str = convertTuple(tup)
print(str)
Thank you sir. Can we just not simply do so by,
Tuple=('1','2','3')
str=convertTuple(Tuple)
print(str)
The aforementioned code also converts a tuple to a string.
Login to add comment
Login to add comment