82.0k views
0 votes
If you want to transform a list of strings input_list into a string with a comma between each item, which of the following would you give as the input to join( )?

a.input_list = ['a', 'b', 'c']
b.','.
c.join(input_list)
d.'a,b,c'

User Jose Reyes
by
7.5k points

1 Answer

6 votes

Final answer:

To transform a list of strings into a single string with commas between items, you should use the ",".join(input_list) syntax in Python.

Step-by-step explanation:

If you want to transform a list of strings input_list into a string with a comma between each item, you would use the join() method of a string object. The correct syntax for the join() method in this case would be ",".join(input_list). This means that you are calling the join() method on a string that consists of a single comma, which will be used to join all items of the list into one string. Every item in the list will be separated by this comma. Therefore, the answer to the question is option b, which is ",".

User Tamir Daniely
by
8.7k points