How to split a string into a list?

In Python, the string method split() can be used to divide a string into a list based on a specified delimiter.


  text = 'apple,banana,orange'
  fruits = text.split(',')


By default, the split() method divides the string at each space. However, you can specify a delimiter, like ',' in this case:


Beginner's Guide to Python