2021年5月2日星期日

Conver list of str numbers in nested list of integers

solving garbage collection problem but because my numbers are in string format the code reads only first number of character (number 10 can be seen as only 1, number 23 only 2 and so on). How can I convert my string list with numbers into nested list of integers so I can keep tracking of the numbers? Or there is a better way to do it?

another_list = ['1', '2', '8']    new_list = ['0,1', '1,7', '2,0', '7,6', '4,5', '5,4', '5,1', '8,4']  

Here are my problem :

while(tar >count):      for x in another_list:          for y in new_list:              if y[0]==x:                  another_list.append(y[2])                  new_list.remove(y)              else:                   sweep.append(y[2])                        count+=1  

file input :

10  p,1  0,1  1,7  r,2  2,0  7,6  4,5  5,4  5,9  8,4  s,8  
https://stackoverflow.com/questions/67362741/conver-list-of-str-numbers-in-nested-list-of-integers May 03, 2021 at 10:08AM

没有评论:

发表评论