0
String to int problem
Lets say i have a string in python that looks like this: """22 33 44 11 22 43 33 20""" When i use .split("\n) It becomes a list of strings,but when i use .split(" ") for each string it dosnt work,the space stays and lst[0][0] will be 2 and not 22. How i fix it and what is the best way to convert it into a list of lists of integers
2 odpowiedzi
+ 1
You can write:
numbers = [int(n) for n in string.split()]
0
Jay Matthews ,i guess s is each line of the list,split() will give me a list of all the numbers in one line,will it be ["22","33","44"] or ["2","2"," ","3" ....]?