+ 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?

2nd Jun 2018, 11:38 PM
Jonah
3 ответов
+ 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()).
3rd Jun 2018, 12:23 AM
David Ashton
David Ashton - avatar
+ 10
use split() list = input().split()
2nd Jun 2018, 11:40 PM
Toni Isotalo
Toni Isotalo - avatar
+ 4
Toni Isotalo you forgot the parentheses. I would do it this way: lst = [x for x in input().split()]
2nd Jun 2018, 11:46 PM
Ulisses Cruz
Ulisses Cruz - avatar