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 365 views
2 answers 397 views
2 answers 455 views
1 answer 340 views
1 answer 254 views
1 answer 340 views
...