Python Convert String into List of Words Example
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:
myString = "ItSolutionStuff.com is a best site!" # Convert String into List newList = myString.split(" ") print(newList)
['ItSolutionStuff.com', 'is', 'a', 'best', 'site!']
myString = "One,Two,Three,Four,Five" # Convert String into List newList = myString.split(",") print(newList)
['One', 'Two', 'Three', 'Four', 'Five']
I hope it can help you.