0

Guys I'm looking for a clean way of splitting a string into a list:

I have this:

myString = 'blue, red, pink, purple'

and I want this:

myString = ['blue', 'red', 'pink', 'purple']

How do I do that?

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by HoneyBadger
1

It is explained in this tutorial. Also a web search for "python string split" will turn up more examples. You can use a split and specify the character, or replace and then split() with the default=space(s).

Edited by woooee: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.