How to split text into a list in Python with split()

1 min

Splitting text is one way to transform your unstructured data into structured data.

Here is an example;

"Egg, Chamomile, Ham" => ["Egg", "Chamomile", "Ham"]

As you can see we transform a string into a list of items.

Here is the code

my_ingredients = "Egg, Chamomile, Ham" 

my_ingredients_list = my_ingredients.split(", ")

print(my_ingredients_list)
Here is how to split text into a list with split()

Here you are! You now know how to split some text into a list in Python with split().

More on fundamentals

If you want to know more about Python fundamentals without headaches... check out the other articles I wrote by clicking just here:

Fundamentals - The Python You Need
We gathered the only Python essentials that you will probably ever need.