+ 2

Input to list

Is there a way to transform an input into a list in Python? Like if the input is a sentence, I want to get each word as an element of the list. Is it possible to do that?

16th Mar 2018, 10:17 AM
Hamsdino
Hamsdino - avatar
2 Answers
+ 11
yes, for example my_input = input("enter something") splited = my_input.split() print(splited) here you ask for input abs then split the input by spaces, which provides you a list
16th Mar 2018, 10:39 AM
__Nick
__Nick - avatar
+ 1
Thank you, that is exactly what I was looking for!
16th Mar 2018, 11:28 AM
Hamsdino
Hamsdino - avatar