Nese Shun
0
Q:

reading a list in python

#to get integer list
integer_list = list(map(int, input().split()))
#to get char or str list, just replace int with str
str_list = list(map(str, input().split()))
#syntax of map(): map(dataType, iterable [, iterable2, iterable3,...iterableN])
6
# creating an empty list 
lst = [] 
  
# number of elemetns as input 
n = int(input("Enter number of elements : ")) 
  
# iterating till the range 
for i in range(0, n): 
    ele = int(input()) 
  
    lst.append(ele) # adding the element 
      
print(lst) 
3
strings = list(map(str,input().split()))
numbers = list(map(int, input().split()))
-1

New to Communities?

Join the community