Question: I am having trouble with this python coding problem Say you have a list value like this: listToPrint = ['apples', 'bananas', 'tofu', 'cats'] Write a

I am having trouble with this python coding problem

Say you have a list value like this:

listToPrint = ['apples', 'bananas', 'tofu', 'cats'] 

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 'apples, bananas, tofu, and cats'. 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.

You can use the following code to start your program. It will let the user type a list

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) 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!