It’s very easy to take array input in Python. Use input() function with map and split() functions.
Example take array input in Python
Simple example code.
If the numbers are provided in the same line then you can use them using a map().
arr = list(map(int, input().split())) print(arr)
If inputs are in different lines then, iterating till the range. Where enter N and then take N number of elements.
n = int(input('Enter how many Array elements: ')) arr = [int(input()) for i in range(n)] print(arr)
Enter how many Array elements: 5
[1, 2, 3, 4, 5]
Do comment if you have any doubts or suggestions on this Python input topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.