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.
#1
So I was given code to essentially begin the assignment, but for some reason I cannot for the life of me figure out where to go with it. I tried to do it on my own without the given code, but it went nowhere.
Essentially the idea is a user has to input words, and the code creates a list, simple, but in this assignment, I have to get the list to add 'and' with a space to the last word. This is where I am getting stuck, but the code I was given to begin makes me even more confused.

listToPrint = []
while True:
    newWord = input("Enter a word to add to the list (press return to stop adding words) > ")
    if newWord == "":
        break
    else:
        listToPrint.append(newWord)
It literally is just putting a word in, and starting the input over again. It doesn't compile a list, it doesn't really do much of anything except repeat. I just don't understand where to start with this, should I just scrap it and start my own code for this?
Reply


Messages In This Thread
Need help with an assignment, not an answer. - by celtickodiak - Sep-30-2019, 10:59 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,170 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