Answers for "python input to list of int"

0

how to take input in python as string and convert into integer list

l=list(map(int,input().split()))
Posted by: Guest on June-27-2021
0

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]
Posted by: Guest on July-20-2021

Code answers related to "python input to list of int"

Python Answers by Framework

Browse Popular Code Answers by Language