Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

split a string into an array of words in python

string = '1-2-3
array_of_words = string.split('-')
print(array_of_words)    # prints ['1', '2', '3']
##################################################
#if you dont pass anything in the split() function,
#the default parameter will be a space
##################################################
string = '1 2 3'
array_of_words = string.split()
print(array_of_words)    # prints ['1', '2', '3']
Comment

PREVIOUS NEXT
Code Example
Python :: python string find 
Python :: glob python 
Python :: python 2.7 datetime to timestamp 
Python :: how to merge two variables to get an array in python 
Python :: print a string with spaces between characters python 
Python :: how to find the path of a python module 
Python :: file uploads django 
Python :: envScriptsactivate.ps1 : File 
Python :: pyinstaller onefile current working directory 
Python :: Tensor.expand_as 
Python :: python repet x time 
Python :: pandas count 
Python :: subprocess.popen no output 
Python :: check file existence python 
Python :: how to make text to speech in python 
Python :: Insurance codechef solution 
Python :: encryption using python 
Python :: python convert object to json 
Python :: BURGERS2 solution 
Python :: how to convert unicode to string python 
Python :: what is += python 
Python :: django fieldset 
Python :: get url param in get django rest 
Python :: numpy array serialize to string 
Python :: how to change todays date formate in python 
Python :: reverse function python 
Python :: argmax implementation 
Python :: pip offline package install 
Python :: data where values in column starts with particular value 
Python :: django forms request 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =