How to convert string to tuple in Python

2 Answers

0 votes
s = "python"

print(tuple(s))


'''
run:

('p', 'y', 't', 'h', 'o', 'n')

'''

 



answered May 10, 2018 by avibootz
0 votes
s = "python"

t = tuple(s)

for i in range(len(t)):
    print(t[i])


'''
run:

p
y
t
h
o
n

'''

 



answered May 10, 2018 by avibootz

Related questions

1 answer 214 views
1 answer 314 views
1 answer 311 views
2 answers 277 views
1 answer 250 views
1 answer 333 views
...