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?
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?
This is basic thing, read tutorial:
http://docs.python.org/library/stdtypes.html#string-methods
Thanks Tony, but that link has too much information, I went over it twice I and didn't find what I needed.
is there a simple way of doing it?
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).
Thanks guys I got it:
myString.split(', ')
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.