frankish
0
Q:

enter values in list 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
a = list(map(int,input("\nEnter the numbers : ").strip().split()))
4
# try block to handle the exception 
try: 
    my_list = [] 
      
    while True: 
        my_list.append(int(input())) 
          
# if the input is not-integer, just print the list 
except: 
    print(my_list) 
0

New to Communities?

Join the community