Asked • 02/14/20

In Python how can I reformat list of words with correct commas and the word "and"?

A student asked for assistance with a Python assignment. She was provided with four lists:


animalList1 = ['dog', 'cat', 'bird', 'tiger', 'lion', 'camel']
animalList2 = ['elephant', 'alligator']
animalList3 = ['horse']
animalList4 = []


The assignment was to create a function that would produce the following output from these or similar lists:


animalList1 - dog, cat, bird, tiger, lion, and camel
animalList2 - elephant and alligator
animalList3 - horse
animalList4 -

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.