Print a list of items separated by commas but with the word "and" before the last item
<p>I've been working on this for two days. This is what the assignment states:</p>

<blockquote>
  <p>Say you have a list value like this: <code>listToPrint = ['apples', 'bananas', 'tofu', 'cats']</code> Write a program that prints a list with all the items separated by a comma and a space, with "and" inserted before the last item. For example, the above list would print <code>'apples, bananas, tofu, and cats'</code>. But your program should be able to work with any list not just the one shown above. Because of this, you will need to use a loop in case the list to print is shorter or longer than the above list.</p>
</blockquote>

<p>This is what I have thus far:</p>

<pre><code>listToPrint = []
while True:
    newWord = input("a, b, and c ")
    if newWord == "":
        break
    else:
        listToPrint.append(newWord)
</code></pre>

<p>The code you've shown appears to be solving a different problem than what your assignment wants you to do. The assignment is focused on <code>print</code>ing the values from a provided <code>list</code>, while your code is all about <code>input</code>ing items from the user and putting them into a list. It could make sense to do one and then the other, but for the assignment that you've given in the comments, the <code>input</code> code is completely irrelevant.</p>

<p>Here's how I'd solve that assignment (probably with code that you don't understand yet):</p>

<pre><code>print("{}, and {}".format(", ".join(list_to_print[:-1]), list_to_print[-1]))
</code></pre>

<p>A more "novice friendly" approach would look more like this:</p>

<pre><code>for item in list_to_print[:-1]:
    print(item, end=', ')
print('and', list_to_print[-1])
</code></pre>

python list python-3.x loops for-loop