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

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 :: django staff_member_required decorator 
Python :: find the area of a circle in python 
Python :: How to Convert Strings to Datetime in Pandas DataFrame 
Python :: python hello world 
Python :: dataframe, sort by columns 
Python :: django model current timestamp 
Python :: python defaultdict 
Python :: how to update the kali linux os from python2 to python3 
Python :: load saved model tensorflow 
Python :: selectfield flask wtf 
Python :: numpy check if 2 array identical 
Python :: python how to open a file in a different directory in mac 
Python :: install python packages from inside within python program 
Python :: python timestamp 
Python :: list of prime numbers in python with list comprehension 
Python :: from imblearn.over_sampling import smote error 
Python :: python get index of first element of list that matches condition 
Python :: Concat and Append DFs Python 
Python :: make sure text is on page selenium python 
Python :: convert a data frame column values to list 
Python :: password manager python 
Python :: pandas new column from others 
Python :: python list except last element 
Python :: how to make html files open in chrome using python 
Python :: python getter decorator 
Python :: lecture de fichier python 
Python :: python divide floor 
Python :: python randomize a dataframe pandas 
Python :: python permutation 
Python :: printing float number python 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =