Converting a single line string to integer array in Python

python, python-2.7

Solution

list(map(int, "1 2 3 4 5".split(" ")))

Problem

I'm trying to learn python through HackerRank, and I've been stuck on reading stdin. The problem gives an array of integers as a single line of text formatted like: ``` 1 2 3 4 5 ``` This should become the array: ``` [1,2,3,4,5]. ``` Since there are spaces in between the numerals in the input, how can I get to an array? I've tried split() and map(), but I kept getting errors or an array that still had spaces. Thank you!

Original source