Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

array as an input in python

list1 = list() #empty list

num = input("How many elements do you want") #user tells the range(optional)

#iterating till user's range is reached
for i in range(int(num)): 
    n = input("Enter a value ")#asking for input of 1 value 
    list1.append(int(n))#adding that value to the list

print(list1)
Comment

python array input from user

#Getting input for array from user
from array import *

a = array("i",[])

n = int(input("Enter the length of array "))

for i in range(n):
    x = int(input("Enter the next value "))
    a.append(x)

print (a)
Comment

taking array input in python

x=[int(input()) for i in range(int(input("How many elements are in list : ")))] print(x) 
Comment

PREVIOUS NEXT
Code Example
Python :: how to append two numpy arrays 
Python :: multiprocessing join python 
Python :: mechanize python 
Python :: install chrome driver python 
Python :: how to convert csv to excel in python 
Python :: any in python 
Python :: how to make button in python 
Python :: What does hexdigest do in Python? 
Python :: bs4 innerhtml 
Python :: python trim leading whitespace 
Python :: __str__ method python 
Python :: forgot django admin password 
Python :: python is program running 
Python :: python thread stop 
Python :: python advanced programs time module 
Python :: pandas fillna with another column 
Python :: pandas if else 
Python :: python do something while waiting for input 
Python :: correlation for specific columns 
Python :: python defaultdict to dict 
Python :: hashing in python using chaining in python 
Python :: python string cut right 
Python :: how to add char to string python 
Python :: import turtle as t 
Python :: sort and remove duplicates list python 
Python :: find element in list that matches a condition 
Python :: python datetime greater than now 
Python :: set value through serializer django 
Python :: python pandas how to get the dataframe size 
Python :: beautifulsoup import 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =