String help

Steve Holden sholden at
Mon Oct 7 16:30:08 CEST 2002

"CheapSkate" <gua81 at> wrote ...
> and that will give me??
> aaa, bbb or ccc?
[Pádraig's suggestion

As with many suggestions you will receive in response to comp.lang.python
questions, the easiest thing is to try running them in an interactive
interpreter session, as follows...

>>> "aaa,bbb,ccc".split(",")
['aaa', 'bbb', 'ccc']

As you can see, the split() function returns a list comprising the
substrings around the separator (which was a comma in this case).

If you want a particular substring you should subscript the resulting list,

>>> r = "aaa,bbb,ccc".split(",")
>>> r[1]

Hope this helps.

Steve Holden                        
Python Web Programming       
Previous .sig file retired to          

More information about the Python-list mailing list