Answers for "how to split sentence with specific word in python"

10

python split sentence into words

sentence = 'Hello world a b c'
split_sentence = sentence.split(' ')
print(split_sentence)
Posted by: Guest on October-12-2020
0

python split string by specific word

>>> mary = 'Mary had a little lamb'
>>> mary.split('a')                 # splits on 'a'
['M', 'ry h', 'd ', ' little l', 'mb'] 
>>> hi = 'Hello mother,\nHello father.'
>>> print(hi)
Hello mother,
Hello father. 
>>> hi.split()                # no parameter given: splits on whitespace
['Hello', 'mother,', 'Hello', 'father.'] 
>>> hi.split('\n')                 # splits on '\n' only
['Hello mother,', 'Hello father.']
Posted by: Guest on October-26-2021

Code answers related to "how to split sentence with specific word in python"

Python Answers by Framework

Browse Popular Code Answers by Language