Python Forum
Need help with an assignment, not an answer.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with an assignment, not an answer.
#5
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
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.
Reply


Messages In This Thread
RE: Need help with an assignment, not an answer. - by jefsummers - Oct-01-2019, 02:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Answer for newbie, Sqlite3 Froger 2 866 Sep-27-2023, 05:33 PM
Last Post: noisefloor
  Coding answer for newbie cg3 2 1,167 Aug-05-2023, 12:17 PM
Last Post: jefsummers
  What am I doing wrong to not get the answer pav1983 7 3,727 Jun-25-2020, 08:53 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020