split word python code example
Example 1: separate a string in python
string = "A B C D"
string2 = "E-F-G-H"
stringlist = string.split()
stringlist2 = string2.split("-", 3)
Example 2: python string to list of chars
l = list('abcd')
l = map(None, 'abcd')
l = [i for i in 'abcd']
import re
l = re.findall('.', 'abcd')
print(l)
Example 3: python split
>>> '1,2,3'.split(',')
['1', '2', '3']
>>> '1,2,3'.split(',', maxsplit=1)
['1', '2,3']
>>> '1,2,,3,'.split(',')
['1', '2', '', '3', '']
Example 4: split word python
text = "Word"
text_list = list(text)
print(text_list)
Example 5: how to split word in python
text= "I am Batman"
splitted_text= text.split()
Print(splitted_text)