Home > Software design >  how to create a list from input argument in python3
how to create a list from input argument in python3

Time:01-15

I want to get an input from user and make a list from that input

I tried to use 'list' for create a list from input but it also make spaces into the list. I can remove spaces but when i put 2 digit number it split it into two element of the list. for example:

L = list(input())
#6 9 10 
print(L)
#['6','','9','','1','0']

but I want to create a list like below :

['6','9','10']

CodePudding user response:

try

_list = input("Enter data:").split()

CodePudding user response:

input_string = input()
L = input_string.split()
print(L)
  • Related