Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to take list of integer as input in python

s = input()
numbers = list(map(int, s.split()))
Comment

python input list of ints

#function to input list of type [cast]
def inputList(msg,cast):
    i = input(msg)[1:-1]
    a = [cast(e) for e in i.split(',')]
    return a
#example code:
#l = inputList("enter a list of numbers: ",int)
#example prompt:
#enter a list of numbers: [1,2,3,4,5]
#expected result for l:
#l = [1,2,3,4,5]
Comment

PREVIOUS NEXT
Code Example
Python :: multiple plot in one figure python 
Python :: print example 
Python :: python convert string to list 
Python :: python heatmap 
Python :: python check variable size in memory 
Python :: numpy scale array 
Python :: subset in python 
Python :: python suppress warnings in function 
Python :: python write byte 
Python :: import matlab python 
Python :: realtime output subprocess 
Python :: device gpu pytorch 
Python :: how to add column to the Dataframe in python 
Python :: get char of string python 
Python :: text from xml doc in python 
Python :: fast output python 
Python :: how to loop through pages of pdf using python 
Python :: python int to char 
Python :: while input is not empty python 
Python :: python excel file 
Python :: convert list of lists to numpy array matrix python 
Python :: comment out multiple lines in python 
Python :: username python 
Python :: Check and Install appropriate ChromeDriver Version for Selenium Using Python 
Python :: python loop list 
Python :: how to read first column of csv intro a list python 
Python :: discord.py permissions 
Python :: python remove file with pattern 
Python :: math module in python 
Python :: python programm zu exe 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =