How to take array input in python?
![](https://pythonpoint.net/wp-content/uploads/2020/11/How-to-install-pil-in-python_-1-1024x576.jpg)
An array is basically a data structure which can hold more than one value at a time. It is a collection or ordered series of elements of the same type.
Arrays can only take a single datatype element.
We can take input of arrays by different methods. Here we’ll study it by seeing examples.
e.g.,
a=int(input("Number of elements in the array:-")) n=list(map(int, input("elements of array:-").strip().split())) print(n)
![](https://pythonpoint.net/wp-content/uploads/2020/11/Screenshot-674-1024x370.png)
Here we can see in the above example that we have used the map function to take the input of the array from the user.
e.g.,
a=[] n=int(input("Number of elements in array:")) for i in range(0,n): l=int(input()) a.append(l) print(a)
![](https://pythonpoint.net/wp-content/uploads/2020/11/Screenshot-676-1024x509.png)
In the above example we have used for loop to get the input of array.
This is all about taking input of array.
Subscribe
Login
Please login to comment
0 Discussion