comma separated string to list python code example
Example 1: python list comma separated string
hobbies = ["basketball", "football", "swimming"]
print("My hobbies are:")
print(", ".join(hobbies))
Example 2: how to split an input in python by comma
lst = input().split(',')
print (lst)
lst = input().split(' ; ')
print (lst)
Example 3: string to list in python comma
str = str (raw_input ("Enter comma separated integers: "))
print "Input string: ", str
list = str.split (",")
print "list: ", list
Example 4: convert list to string separated by comma python
converted_list = [str(element) for element in a_list]
Example 5: 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']