For example, I have:

lst = ['1,2' , '3,4' , '6,5'] 

How do I make it so:

 lst = [[1,2] , [3,4] , [6,5]] 

    3 answers 3

     lst = ['1,2' , '3,4' , '6,5'] newLst = [[int(j) for j in i.split(',')] for i in lst] print(newLst) # [[1, 2], [3, 4], [6, 5]] 

      For example, like this:

       lst = ['1,2' , '3,4' , '6,5'] new_list = [] for element in lst: data = element.split(',') print(data) nlst = [] nlst.append(int(data[0])) nlst.append(int(data[1])) new_list.append(nlst) print(new_list) 
         lst = ['1,2', '3,4', '6,5'] newLst = [list(map(int, x.split(','))) for x in lst] print(newLst) 
        • Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky