list to comma separated string code example

Example 1: python list comma separated string

hobbies = ["basketball", "football", "swimming"]
print("My hobbies are:")      	# My hobbies are:
print(", ".join(hobbies)) 		# basketball, football, swimming

Example 2: javascript array to comma separated string

var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"

Example 3: convert list to string separated by comma python

converted_list = [str(element) for element in a_list]

Example 4: list from comma separated string python

>>> my_string = 'A,B,C,D,E'
>>> my_list = my_string.split(",")
>>> print my_list
['A', 'B', 'C', 'D', 'E']