1foo = "A B C D"
2bar = "E-F-G-H"
3
4# the split() function will return a list
5foo_list = foo.split()
6# if you give no arguments, it will separate by whitespaces by default
7# ["A", "B", "C", "D"]
8
9bar_list = bar.split("-", 3)
10# you can specify the maximum amount of elements the split() function will output
11# ["E", "F", "G"]
1>>> '1,2,3'.split(',')
2['1', '2', '3']
3>>> '1,2,3'.split(',', maxsplit=1)
4['1', '2,3']
5>>> '1,2,,3,'.split(',')
6['1', '2', '', '3', '']
7
1# How to spit a word :
2
3text = "Word"
4text_list = list(text)
5print(text_list)
6
7# Output :
8# ["W", "o", "r", "d"]