1sentence = 'Hello world a b c'
2split_sentence = sentence.split(' ')
3print(split_sentence)
1def split(word):
2 return [char for char in word]
3
4word = "word"
5print(split(word))
6#output: ["w", "o", "r", "d"]
7
1>>> mary = 'Mary had a little lamb'
2>>> mary.split('a') # splits on 'a'
3['M', 'ry h', 'd ', ' little l', 'mb']
4>>> hi = 'Hello mother,\nHello father.'
5>>> print(hi)
6Hello mother,
7Hello father.
8>>> hi.split() # no parameter given: splits on whitespace
9['Hello', 'mother,', 'Hello', 'father.']
10>>> hi.split('\n') # splits on '\n' only
11['Hello mother,', 'Hello father.']