Answers for "how to take a list of numbers as input in python"

11

get list input from user in python

a = list(map(int,input("nEnter the numbers : ").strip().split()))
Posted by: Guest on September-17-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
0

how to take list input in python

for i in range(0, n): 
    ele = int(input()) 
  
    lst.append(ele)
Posted by: Guest on October-01-2020

Code answers related to "how to take a list of numbers as input in python"

Python Answers by Framework

Browse Popular Code Answers by Language