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 :: python random hex color 
Python :: hide root window tkinter 
Python :: Installing python cryptography 
Python :: python gui programming using pyqt5 
Python :: days of week 
Python :: python cv2 read image grayscale 
Python :: python random number between 1 and 100 
Python :: python find the key with max value 
Python :: spammer bot python 
Python :: pandas plotly backend 
Python :: database default code in settings django 
Python :: python regex count matches 
Python :: how to make my jupyter prin full array 
Python :: python make txt file 
Python :: python selenium hover over element 
Python :: python schedule timezone 
Python :: pip code for pytube 
Python :: display python 001 
Python :: python random date between range 
Python :: Generate random image np array 
Python :: python show interpreter path 
Python :: random character generator python 
Python :: pretty print pandas dataframe 
Python :: import reverse_lazy 
Python :: how to install python3 on ubuntu 
Python :: clibboard to png 
Python :: return maximum of three values in python 
Python :: how to install gym 
Python :: python split path at level 
Python :: sklearn roc curve 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =