String help

Daniel T. a at b.c
Mon Oct 7 10:34:43 EDT 2002


In article <ans2k7$efd$1 at lust.ihug.co.nz>,
 "CheapSkate" <gua81 at XXXyahoo.com> wrote:

> and that will give me??
> aaa, bbb or ccc?
> 
> Thanks
> 
> "Padraig Brady" <Padraig at Linux.ie> wrote in message
> news:3DA18C4C.1050705 at Linux.ie...
> > "aaa,bbb,ccc".split(',')
> >
> > Pádraig.

It gives you all three.

Try it:

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

(ie it returns a list of strings, each with the approprate part)

or

>>> a, b, c = "aa,bb,cc".split(',')
>>> a
'aa'
>>> b
'bb'
>>> c
'cc'

(ie each element on the left is assigned a part of the string.)

-- 
In early 1955, Sammet recalled, her boss, Arthur Hauser, asked her if
she wanted to be a programmer. Sammet replied, "What's a programmer?"
Hauser said he did not know, but he knew the computer project would
require a programmer... "That's how I became a programmer," Sammet
explained, smiling at the memory.                -- Steve Lohr "Go To"



More information about the Python-list mailing list