Bryce H.

asked • 02/02/23

how to use comma code in python

Comma Code

Say you have a list value like this:

characters = ["Thor", "Thanos", "Black Panther", "Iron Man", "Hulk", "Batman", "Captain America"]

Write Python code that coverts the list into a string with all the items separated by a comma and a space, with 'and' inserted before the last item. For example, converting the characters list look like this:

'Thor, Thanos, Black Panther, Iron Man, Hulk, Batman and Captain America.'


1 Expert Answer

By:

EDWARD A. answered • 02/02/23

Tutor
5.0 (283)

PhD Data Scientist & AI Specialist: R, Python, Tableau, Bioinformatics

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.