Oct-01-2019, 02:04 PM
Couple of things -
You say it does not compile a list. It does. The listToPrint.append(newWord) appends the entered words to the list building it along.
It doesn't print anything because you don't tell it to print anything. Once you have listToPrint complete (the user entered a blank line), you then need to print(listToPrint).
The challenge is then as ichabod801 said. When the user enters that blank line you want to break to your print statement, but before you print you need to modify the last item in the list (until the person enters the blank line you never know if the item entered will be the last).
So, take your original code and add
You say it does not compile a list. It does. The listToPrint.append(newWord) appends the entered words to the list building it along.
It doesn't print anything because you don't tell it to print anything. Once you have listToPrint complete (the user entered a blank line), you then need to print(listToPrint).
The challenge is then as ichabod801 said. When the user enters that blank line you want to break to your print statement, but before you print you need to modify the last item in the list (until the person enters the blank line you never know if the item entered will be the last).
So, take your original code and add
listToPrint[-1]="and "+listToPrint[-1] print(listToPrint)to the end, unindented. listToPrint[-1] is the last item. You will append "and " to the front of that and store it back into that last item. Then print it to see the result.