How to convert string consisted of several numbers with a space into a list of integer values of that same string?

Question:

I have a string that consists of numbers with a space.

myString = "3 45 12"

I want to make a list of integer values derived from that string, ex:

myList = [3, 45, 12]
Asked By: bit_scientist

||

Answers:

Try this:

myString = "3 45 12"
numericdata = myString.split(' ')
numbers = []

for i in numericdata:
    numbers.append(int(i))

print(numbers)
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.