How can strings be split into substrings in Python?
In Python, we can use the split() method to divide a string into sub-strings. This method takes a delimiter as a parameter and returns a list containing the divided sub-strings.
Here is a simple example:
s = "hello,world"
substrings = s.split(",")
print(substrings)
Output:
['hello', 'world']
In the example above, we used a comma as a delimiter to split the string “hello, world” into two substrings, “hello” and “world”, and stored them in the list “substrings”.