Re: [Tutor] Searching backwards from end of string

2009-07-11 Thread Luke Paireepinart
Angus,I don't think you're at fault but you must keep in mind that a lot of people that read this list get a lot of the same questions repeatedly, only worded slightly differently. I also didn't notice that you used slicing in your first message, and in your second message I just saw that you quote

Re: [Tutor] Searching backwards from end of string

2009-07-11 Thread Angus Rodgers
Robert Berman wrote: >A nifty 'notation like "[::-1]"' is an example of something called >slicing which you will find very well explained in 6.1 of CORE PYTHON >PROGRAMMING. I thought that you had reviewed this since it precedes the >questions in Chapter 6. It is a very handy tool for not only s

Re: [Tutor] Searching backwards from end of string

2009-07-10 Thread Robert Berman
On Fri, 2009-07-10 at 20:55 +0100, Angus Rodgers wrote: > On Fri, 10 Jul 2009 11:57:21 -0400, Robert Berman > wrote: > > >I think you are looking for a complex solution. > > Hardly. In my opinion your code w was overly complex for what you were attempting to do. I would not be so presumptuous

Re: [Tutor] Searching backwards from end of string

2009-07-10 Thread Angus Rodgers
On Fri, 10 Jul 2009 11:57:21 -0400, Robert Berman wrote: >I think you are looking for a complex solution. Hardly. >How about the following example: > > >In [31]: s1='abcdeefghijkl' #find last 'e' > >In [32]: s2=s1[::-1]#reverses s1 > >In [33]: j=s2.find('e') #finds first 'e' in reversed st

Re: [Tutor] Searching backwards from end of string

2009-07-10 Thread Robert Berman
I think you are looking for a complex solution. How about the following example: In [31]: s1='abcdeefghijkl' #find last 'e' In [32]: s2=s1[::-1]#reverses s1 In [33]: j=s2.find('e') #finds first 'e' in reversed string In [36]: ind=len(s1)-j-1 #index into s1 where last occurrence of 'e' i