How to convert a list into a tuple with Python

2 Answers

0 votes
lst = [1, 2, 3, 4, 5] 

tpl = tuple(lst)

print(tpl) 


'''
run:

(1, 2, 3, 4, 5)

'''

 



answered Dec 25, 2019 by avibootz
0 votes
lst = [1, 2, 3, 4, 5] 

tpl = (*lst, ) 

print(tpl) 


'''
run:

(1, 2, 3, 4, 5)

'''

 



answered Dec 25, 2019 by avibootz

Related questions

2 answers 236 views
2 answers 281 views
2 answers 322 views
1 answer 242 views
1 answer 170 views
1 answer 224 views
...