Python String split() Method
Splits the string by the given separator, from left to right. An array is returned for the separated strings. An optional number of occurrences can be specified.
string.split(separator = " ", max_strings = -1)
||Optional. The string by which to split the given string. The default is a space (" ")|
||Optional. The maximum number of strings to return. The default is -1 which means "all strings that resulted from the split operation".|
str = 'You say tomato, I say tomato, the French say tomate.' print(str.split('tomato')) print(str.split('tomato', 1))
['You say ', ', I say ', ', the French say tomate.'] ['You say ', ', I say tomato, the French say tomate.']
If you specify max_strings then the number of items that will be returned is max_strings+1.