Python Split Method: How to Use split()

In Python, you can use the split() method to split a string. This method takes a parameter as a separator, splits the string according to the specified separator, and returns a list containing the separated substrings.

For example,

s = "apple,banana,orange"
fruits = s.split(",")
print(fruits)  # ['apple', 'banana', 'orange']

In the example above, we split the string “s” by commas and return a list containing the split substrings.

bannerAds