Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get list input from user in python

a = list(map(int,input("
Enter the numbers : ").strip().split()))
Comment

Get a list as input from user

# number of elements
n = int(input("Enter number of elements : "))

# Below line read inputs from user using map() function
a = list(map(int,input("
Enter the numbers : ").strip().split()))[:n]

print("
List is - ", a)
Comment

PREVIOUS NEXT
Code Example
Python :: plot pil image colab 
Python :: types of dict comprehension 
Python :: python iterate files 
Python :: Splitting training and test data using sklearn 
Python :: pytorch transpose 
Python :: get ip address py 
Python :: custom jupyter notebook 
Python :: get multiple inputs in python 
Python :: python print with 2 decimals 
Python :: calculate mean median mode in python 
Python :: copy only some columns to new dataframe in r 
Python :: difference between set and tuple in python 
Python :: value_counts with nan 
Python :: turn list in to word python 
Python :: split at the second occurrence of the element python 
Python :: Python program to implement linear search and take input. 
Python :: pandas dataframe compare two dataframes and extract difference 
Python :: column to int pandas 
Python :: string print in pattern in python 
Python :: pandas split column with tuple 
Python :: huggingface transformers change download path 
Python :: django queryset to form 
Python :: python text input 
Python :: how to convert each string to a category or int in python dataframe 
Python :: assign a same value to 2 variables at once python 
Python :: python - calculate the value range on a df 
Python :: python iterating through a string 
Python :: integer xticks 
Python :: python Modulo 10^9+7 (1000000007) 
Python :: how to get last n elements of a list in python 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =