How to Split String Into Substrings in Python


In this example we will show how to split the string into substrings if it finds instances of the separator using the split() method in Python.

Source Code

my_str = 'I, love, Python'

print(my_str)
print(my_str.split(','))

Output:

I, love, Python
['I', ' love', ' Python']
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments