In this example, we will see how we can split the string by a separator. In any programming language, working with a string  datatype is normal, and there are two most essential operations regarding string which is  String Concatenation and String Split.

Python split()

Python string split() is an inbuilt function that splits the string into the list. The split() method returns the list of strings after breaking the given string by a specified separator. You can specify the separator, the default separator is any whitespace.

Note: When max is specified, the list will contain the specified number of elements plus one.

Syntax

str.split(separator, limit)

Parameters

The separator parameter is the delimiter which splits the string from a specified character.

The limit parameter is the optional limit, and if provided, then it splits the string into the maximum of the provided number of times.

#python #programming #python string split

Python String split: How to Split String into List in Python
5.15 GEEK