How to split a string into a list?
text.split()
This should be enough to store each word in a list. words
is already a list of the words from the sentence, so there is no need for the loop.
Second, it might be a typo, but you have your loop a little messed up. If you really did want to use append, it would be:
words.append(word)
not
word.append(words)
Splits the string in text
on any consecutive runs of whitespace.
words = text.split()
Split the string in text
on delimiter: ","
.
words = text.split(",")
The words variable will be a list
and contain the words from text
split on the delimiter.