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 :: python extract email attachment 
Python :: how to count repeated words in python 
Python :: python round without math 
Python :: python logistic function 
Python :: .replit file python 
Python :: matplotlib savefig cutting off graph 
Python :: django rest framework function based views 
Python :: box plot python 
Python :: how to login using email in django 
Python :: Python3 seconds to datetime 
Python :: get method in python dictionary 
Python :: lable on graph in matplotlib 
Python :: check if an object has an attribute in Python 
Python :: python threading return value 
Python :: urllib.request.urlopen with headers 
Python :: name, *line = input().split() 
Python :: find nan values in pandas 
Python :: similarity index in python 
Python :: compress excel file in python 
Python :: waiting in python. time , sleep 
Python :: dask read csv 
Python :: generate n different colors matplotlib 
Python :: input for competitive programming 
Python :: class indexing 
Python :: download unsplash images python no api 
Python :: create column with values mapped from another column python 
Python :: make parameter optional python 
Python :: xml depth python 
Python :: django bulk update 
Python :: how to access items in a list 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =