Q:

Python3 - list() is taking every character in the string as an element, not every word

I want to make a list of numbers via input
When I type:
>>> list(input())
1 23 456 7890
['1', ' ', '2', '3', ' ', '4', '5', '6', ' ', '7', '8', '9', '0']

how to let it print this:
[1, 23, 456, 7890]

?

A:

You can try
[int(e) for e in input().split()]

This is a list comprehension that converts all split string in integers. It will raise an exception if string can not be converted to integers.

