![]() |
VOOZH | about |
Python split() method is used to break a string into a list of smaller strings based on a specified delimiter. It is commonly used for text parsing, string extraction and processing CSV or space-separated data.
['one', 'two', 'three']
Explanation:
str.split(separator, maxsplit)
Parameters
Returns
['geeks', 'for', 'geeks'] ['geeks', ' for', ' geeks'] ['geeks', 'for', 'geeks'] ['Ca', 'Ba', 'Sa', 'Fa', 'Or']
Note: When no separator is given, multiple consecutive spaces are treated as a single separator.
['Hello', 'world']
The maxsplit parameter is used to control how many splits to return after the string is parsed. Even if there are multiple splits possible, it'll only do maximum that number of splits as defined by the maxsplit parameter.
['geeks, for, geeks, hello'] ['geeks', 'for', 'geeks', 'hello'] ['geeks', 'for, geeks, hello']
Explanation:
String parsing involves splitting a string into smaller segments based on a specific delimiter or pattern. This can be easily done by using a split() method in Python.
['Hello', 'geek,', 'Welcome', 'to', 'GeeksforGeeks.']