+ 2
List Input
Does anyone know a way to turn input into a list in Python? I tried list=list[input()] but that didn’t work. Any ideas?
3 Antworten
+ 13
All you need is
lst = input().split()
as this automatically generates a list of all the strings separated by spaces, i.e the words.
If you want a list of all the characters, you can use lst = list(input()).
+ 10
use split()
list = input().split()
+ 4
Toni Isotalo you forgot the parentheses.
I would do it this way:
lst = [x for x in input().split()]