I'm reaching out to you all for help with this list project I'm working on. What I need to do is create a program that asks for the user to enter a word, and continue to ask until the user hits enter without typing anything. Once the user hits enter without typing anything, I need to create a list of all the words entered. The code I've pasted below does that currently, however, I need to figure out how to add "and" before the last option. I also need to figure out how to add "and" only if we already have more than one word entered.
Here is the code:
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) print('Your items are:') #print items in list here for newWord in listToPrint: print(newWord, end=' ')
Would I need to use an if statement loop to create the second portion to add the "and" segment?
Please help! Thank you!