How to convert a list into a list of lists in Python

1 Answer

0 votes
lst = ['aaa, bbbb', 'xxx, yyy', '123, 456', '3.14, 8.91'] 
           
lst_tst = [] 
  
for item in lst: 
    tmp = item.split(', ') 
    lst_tst.append(tmp) 
  
print(lst_tst)


'''
run:

[['aaa', 'bbbb'], ['xxx', 'yyy'], ['123', '456'], ['3.14', '8.91']]

'''

 



answered Dec 23, 2019 by avibootz

Related questions

2 answers 360 views
5 answers 540 views
1 answer 206 views
2 answers 389 views
1 answer 315 views
...