[Tutor] Why is this only catching one occurance?
Carroll, Barry
Barry.Carroll at psc.com
Fri Oct 27 22:16:01 CEST 2006
Chris:
See below.
> -----Original Message-----
> Message: 7
> Date: Fri, 27 Oct 2006 12:20:51 -0700
> From: "Chris Hengge" <pyro9219 at gmail.com>
> Subject: Re: [Tutor] Why is this only catching one occurance?
> To: "Bob Gailer" <bgailer at alum.rpi.edu>
> Cc: Tutor <tutor at python.org>
> Message-ID:
> <c25107380610271220y2fb08002je41b54e52bcbda5b at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I've tried to use your example:
> for unWantedItem in directoryList[,,-1]:
>
> but I get an error:
> for unWantedItem in directoryList[,,-1]:
> ^
> SyntaxError: invalid syntax
>
<<SNIP>>
The problem is the commas. Python uses colons to describe slices. Try
this instead:
>>>>> for unWantedItem in directoryList[::-1]:
I think that will work for you.
Regards,
Barry
barry.carroll at psc.com
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.
-Quarry worker's creed
More information about the Tutor
mailing list