How to convert a list into tuple of lists in Python

2 Answers

0 votes
lst = ['python, 7123', 'php, 9834', 'c++, 6321', 'java, 2345'] 
  
tpl_lst = tuple([s] for s in lst) 
  
print(tpl_lst) 



'''
run:

(['python, 7123'], ['php, 9834'], ['c++, 6321'], ['java, 2345'])

'''

 



answered Dec 23, 2019 by avibootz
0 votes
lst = ['python, 7123', 'php, 9834', 'c++, 6321', 'java, 2345'] 
  
tpl_lst = tuple(map(list, zip(lst))) 
  
print(tpl_lst) 



'''
run:

(['python, 7123'], ['php, 9834'], ['c++, 6321'], ['java, 2345'])

'''

 



answered Dec 23, 2019 by avibootz

Related questions

2 answers 389 views
1 answer 249 views
2 answers 338 views
1 answer 242 views
5 answers 539 views
...