problems getting a single item out of a list

Peter Hansen peter at engcorp.com
Tue Sep 17 08:27:26 EDT 2002


Manuel Hendel wrote:
> On Tue, Sep 17, 2002 at 12:30:52AM -0700, Sean 'Shaleh' Perry wrote:
> 
>>just use fields[2] (you start counting at zero).
> 
> 
> This worked fine:
> 
> domainfield = fields[3]
> 
> But the next problem is, that after a 
> 
> domainfield = string.split(fields[3])
> 
> domainfield seams to be a list item again.
> 
> print domainfield
> 
> ['142000']

Well, you don't show what fields[3] contained before the
string.split, but in any case split() returns a list by
definition, so what else did you expect?  If you want to
get the first item from the split list, just use
domainfield[0] this time...

-Peter




More information about the Python-list mailing list