Guys, how do I add an item to a list using a loop?
My loop in a nutshell does this:
for w in book_line.split(" "):
word_list = []
if w != "":
word_list.append(w.lower())
return word_list
While experimenting with this I got mainly two results:
1.) When I use return word_list, it only puts the first word of the book into my list.
2.) When I use print word_list I prints just one word as well. but goes through each word individually.
I also tried putting word_list = [] in different parts of the code, and that opened up a whole new can of worms. :(
Question: How do I "dump" the results from my for loop(the words). into my list without having them cancel each other out?