How to read an array of integers from single line of input in python3


I want to read an array of space-separated elements from a single line in python how can I do that?

1 Answer

4 years ago by

arr = list(map(int, input().split()))

We will take the input as a string then split it to a list and for every element in the list we map the value to convert it into a integer and append it to a array arr

4 years ago by Divya