Python - String Method - split() Tutorial
It will break or Split the string at the specified separator and return a list of strings.
Syntax-
String.split(separator,maxsplit)
#separator- (Optional) Separator value at which
split should occur in the given string
#maxsplit- (Optional) Maximum number of splits that should occur in String.
By default there is no limit in number of split.
Example-
str1 = "Python is a cross-platform object-oriented general-purpose
, high-level programming language"
print(str1.split())
print(str1.split("-"))
print(str1.split("-",2))
Output-
['Python', 'is', 'a', 'cross-platform', 'object-oriented', 'general-purpose,',
'high-level', 'programming', 'language']
['Python is a cross', 'platform object', 'oriented general', 'purpose, high',
'level programming language']
['Python is a cross', 'platform object', 'oriented general-purpose,
high-level programming language']