Python Convert String into List of Words Example

Hi Dev,

There are several ways to convert strings into a list in python. we will use split() and strip() functions to convert string into list. so let's see the below examples.

You can use these examples with python3 (Python 3) version.

let's see below a simple example with output:

Example 1
myString = " is a best site!"
# Convert String into List
newList = myString.split(" ")


['', 'is', 'a', 'best', 'site!']

Example 2
myString = "One,Two,Three,Four,Five"
# Convert String into List
newList = myString.split(",")


['One', 'Two', 'Three', 'Four', 'Five']

I hope it can help you.