1def split(txt, seps):
2 default_sep = seps[0]
3 # we skip seps[0] because that's the default separator
4 for sep in seps[1:]:
5 txt = txt.replace(sep, default_sep)
6 return [i.strip() for i in txt.split(default_sep)]
7
8
9>>> split('ABC ; DEF123,GHI_JKL ; MN OP', (',', ';'))
10['ABC', 'DEF123', 'GHI_JKL', 'MN OP']
1string = "this is a string" # Creates the string
2splited_string = string.split(" ") # Splits the string by spaces
3print(splited_string) # Prints the list to the console
4# Output: ['this', 'is', 'a', 'string']