Answers for "python input list of integers"

7

how to get user input of list in python

# number of elements 
n = int(input("Enter number of elements : ")) 
  
# Below line read inputs from user using map() function  
a = list(map(int,input("nEnter the numbers : ").strip().split()))[:n] 
  
print("nList is - ", a)
Posted by: Guest on May-04-2020
0

HOW TO GET LIST OF NUMBERS AS AN INPUT IN PYTHON

# number of elements
n = int(input("Enter number of elements : "))
  
# Below line read inputs from user using map() function 
a = list(map(int,input("nEnter the numbers : ").strip().split()))[:n]
  
print("nList is - ", a)
Posted by: Guest on April-06-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 list of integers"

Python Answers by Framework

Browse Popular Code Answers by Language