Dave wrote:
Hey there, having a bit of problem iterating through lists before i go
on any further, here is
a snip of the script.
--
d = "a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 a3 b3 c3 d3 e3 a4 b4 c4 d4 e4 a5 b5
c5 d5 e5"
inLst = d.split()
hitLst = []

hitNum = 0
stopCnt = 6 + hitNum

for i in range(hitNum,len(inLst), 1):
        if i == stopCnt: break
        hitLst.append(inLst[i])

print hitLst
--
$ python helper.py
['a1', 'b1', 'c1', 'd1', 'e1', 'a2']


This works fine for my purposes, what I need is an outer loop that
goes through the original list again and appends my next request.

ie.

hitNum = 5

which will return:

['a2', 'b2', 'c2', 'd2', 'e2', 'a3']

and append it to the previous one.

ie:

['a1', 'b1', 'c1', 'd1', 'e1', 'a2']
['a2', 'b2', 'c2', 'd2', 'e2', 'a3']


not really sure how to do this right now though, been trying several
methods with no good results.

btw, just creating lagged values (sort of shift registers) on the
incoming signal

Many thanks,

Dave

Dave,

You are going to need to supply us with more info to help.

1) Are you always going to want to get 6 elements from the list
2) Are you always going to want to step by 5 elements as your offset each time through the outer loop? 3) Is your requirement just to split inLst into equal length lists and append them together into a list?

Depending on your answers this might be quite easy.

-Larry
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to