Want to split a string?
To split a string, we use the method .split().
This method will return one or more new strings. All substrings are returned in the list datatype.
We can split a string based on a character.
s = "To convert the result to"
parts = s.split(" ")
Any character can be used. If you want to get sentences you could use:
s = "Python string example. We split it using the dot character."
parts = s.split(".")
This will result in: