Python String to Integer Conversion



Hi folks.

I want to convert a String input to an Integer.

So far I have:

print 'Enter the numbers.'
read = sys.stdin.readline()
array = read.split()

firstNumber = int(array[0])
secondNumber = int(array[1])
thirdNumber = int(array[2])
...

Problem with this is that I think it's rather inefficient, as you must convert each cell one by one...

Is there a more efficient alternative solution to this conversion process???

Cheers,
ThompsonSensibl



Use following to create array of integers:

array = [int(item) for item in read.split()]