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

split a string by comma in python

str = 'apple,orange,grape'

#split string by ,
chunks = str.split(',')

print(chunks)
Comment

PREVIOUS NEXT
Code Example
Python :: python compare if 2 files are equal 
Python :: text size legend to bottom matplotlib 
Python :: how to download file in python 
Python :: mouse module python 
Python :: import stopwords 
Python :: python check list contains another list 
Python :: random string generator python 
Python :: log base in python 
Python :: convert birth date to age pandas 
Python :: python random choice in list 
Python :: convert categorical data type to int in pandas 
Python :: python keyboard press 
Python :: plot python x axis range 
Python :: export csv from dataframe python 
Python :: check if number in range 
Python :: nb_occurence in list python 
Python :: random py 
Python :: tkinter change button text 
Python :: how to subtract dates in python 
Python :: parameter grid 
Python :: python image plot 
Python :: Python pandas drop any row 
Python :: pandas groupby histogram 
Python :: python find location of module 
Python :: cprofile implementation 
Python :: how to create a database in python 
Python :: python numpy arrays equality 
Python :: python utf8 
Python :: python df round values 
Python :: argparse list 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =