1def split(word):
2 return [char for char in word]
3
4# Driver code
5word = 'geeks'
6print(split(word))
7
8#Output ['g', 'e', 'e', 'k', 's']
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"]
1file='/home/folder/subfolder/my_file.txt'
2file_name=file.split('/')[-1].split('.')[0]
1txt = "apple#banana#cherry#orange"
2
3# setting the maxsplit parameter to 1, will return a list with 2 elements!
4x = txt.split("#", 1)