Use map
:
arr = list(map(int, input().split()))
Just adding, in Python 2.x you don't need the to call list()
, since map()
already returns a list
, but in Python 3.x "many processes that iterate over iterables return iterators themselves".
This input must be added with () i.e. parenthesis pairs to encounter the error. This works for both 3.x and 2.x Python