Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to split string with comma in python

# We can use the split() function and put a "," in the parameter 
# It'll return a list with the string split up by commas.
txt = "hello, my name is Peter, I am 26 years old"

x = txt.split(",")
print(x)
Comment

python list comma separated string

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

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']
Comment

PREVIOUS NEXT
Code Example
Python :: change plot size matplotlib python 
Python :: emoji in python 
Python :: delete a row in pandas dataframe 
Python :: sqlalchemy check if database exists 
Python :: how to log ip addresses in django 
Python :: python speech recognition module 
Python :: scikit learn svm 
Python :: how can I plot model in pytorch 
Python :: python maths max value capped at x 
Python :: pandas join two series on index 
Python :: python datetime to timestamp 
Python :: my pygame window wont stay open 
Python :: deleting duplicates in list python 
Python :: pyinstaller 
Python :: pd combine date time 
Python :: pandas repeat rows n times 
Python :: selenium zoom out python 
Python :: how to get current date in python 
Python :: python - exchange rate API 
Python :: execute python in notepad++ 
Python :: plotly backend pandas 
Python :: how to stop python prompt 
Python :: python json load file 
Python :: get time in ms python 
Python :: difference between sort and sorted 
Python :: pytorch use multiple gpu 
Python :: count items in list 
Python :: how to convert multi list to dict 
Python :: how to check if a number is a perfect square python 
Python :: default ordering django 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =