+ 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?
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
+ 1
Thank you, that is exactly what I was looking for!