Python split() method splits the string into a comma-separated list.
Python String
- Python string is that the collection of the characters surrounded by single quotes, double quotes, or triple quotes.
- The computer doesn’t understand the characters; internally, it stores manipulated character because of the combination of the 0’s and 1’s.
- Each character is encoded within the ASCII or Unicode character. So we will say that Python strings also are called the collection of Unicode characters.
Python String split()
- Python split() method splits the string into a comma-separated list.
- split() method returns a list of strings after breaking the given string by the specified separator.
- This method takes two parameters and both are optional.
Syntax
Parameters :
- separator : This is often a delimiter. The string splits at this specified separator. If isn’t provided then any white space may be a separator.
- maxsplit : It’s a number, which tells us to separate the string into maximum of provided number of times. If it’s not provided then there’s no limit.
- Returns : Returns a list of strings after breaking the given string by the specified separator.
Example 1:
Output:
Example 2:
Output