In my last post about I have discussed about the introduction to array. And in this post, I am gonna show how you can print array by supplying your own values. For this we have to create an empty array, then specify the length of array to be constructed and ask user to input value for the array and then append the user input values to the empty array.
Here's the code doing the same process:
from array import *
NewArray=array('i',[])
len_array=int(input("Enter the size of arrays to be created: "))
for i in range(len_array):
user_input=int(input("Enter the next value:"))
NewArray.append(user_input)
print(NewArray)
Here's the sample output of this code when executed:
You can copy paste this code and run it online here.