I'm new to python and I'm trying to take words in a string and put them into a list, but I'm having trouble. This is what it should look like:
Input: sentence = "abcde that i like."
Output: list_of_words = ['abcde', 'that', 'i', 'like.']
This is what I've tried:
word = ""
list_of_words = []
sentence = "abcde that i like."
for letter in sentence:
if letter != " ":
word += letter
else:
list_of_words.append(word)
word = ""
print(list_of_words)
When I run the code the output is:
['abcde', 'that', 'i']
I'm trying to figure it out why the last word isn't included in the list.