I Want To Change A Tuple Into String Without Joining It In Python. How Could I Do That?
For Example: I want to change t=('a', 'b', 'c') to s='a', 'b', 'c'
Solution 1:
t = ('a', 'b', 'c')
s = 'a','b', 'c'print(s==t)
# output True
if you want s = 'a,b,c'
then you can do it by joining which you do not want to do. Also, it's useless to write 'a','b','c'
as string, however you can do that by using commented code. Please consider writing s = a,b,c
s = ''for i in t:
s += str(',') + i # s += str(',') + str("'") + i + str("'")
s = s[1:]
Solution 2:
Solution 3:
t=('a', 'b', 'c')
print(list(t))
['a', 'b', 'c']
",".join(list(t))
Post a Comment for "I Want To Change A Tuple Into String Without Joining It In Python. How Could I Do That?"