So, I had problems with the code before, because I was getting an empty string when I repeated through foodList.
Someone suggested using the "if x.strip ():" method, as shown below.
for x in split: if x.strip(): foodList = foodList + [x.split(",")]
This works great, but I just wanted to know what that really means. I know that it removes spaces, but the if statement above would not say if x had empty space, then true. What would be the opposite of what I wanted? Just wanted to get around my terminology and what it does behind the scenes.
source share