What is the difference between split() and split(' ')?
What is the return type of the split() function?
Can I Use Split with Non-String Objects?
According to the official documentation:
string.split(s[, sep[, maxsplit]]): If the second argument sep is present and notNone, it specifies a string to be used as the word separator.
So characters.split('cat') will return an array where the string is separated by the word cat. if you will call "1cat2cat3".split('cat'), you will get ["1", "2", "3"].
In your case, the string catcat can be represented as '' + 'cat' + '' + 'cat' + '', so 'catcat'.split('cat')
will return ['', '', ''].
The python documentation should answer your question:
Quoted here:
...delimiters... are deemed to delimit empty strings (for example,
'1,,2'.split(',')returns['1', '', '2']).
In your case, the string catcat is treated as:
'<empty_str>cat<empty_str>cat<empty_str>' with cat as delimiter.