Re: [Tutor] Detecting sequences in lists

2007-08-27 Thread Kent Johnson
Tino Dai wrote: > Hi Everybody, > >Thank you so much for the information on sets. I think that that > has certain uses, but in my case I can't find a way. I have been > thinking about sequences in a list. Let me give you an example: > > tset = [ 1,2,4,0,0,1,2,4,4] > > What I want to do

Re: [Tutor] Detecting sequences in lists

2007-08-27 Thread Lutz Horn
Hi, DIY is easy. On Mon, 27 Aug 2007 09:20:53 -0400, "Tino Dai" <[EMAIL PROTECTED]> said: > What I want to do is detect the 1,2,4 sequence and perhaps how many. >>> tset = [ 1,2,4,0,0,1,2,4,4] >>> s = [1, 2, 4] >>> c = 0 >>> for i in range(len(tset) - len(s)): ... if tset[i:i+len(s)] == s: .

[Tutor] Detecting sequences in lists

2007-08-27 Thread Tino Dai
Hi Everybody, Thank you so much for the information on sets. I think that that has certain uses, but in my case I can't find a way. I have been thinking about sequences in a list. Let me give you an example: tset = [ 1,2,4,0,0,1,2,4,4] What I want to do is detect the 1,2,4 sequence and pe