[Tutor] circular looping
Bala subramanian
bala.biophysics at gmail.com
Mon May 24 18:35:21 CEST 2010
Friends,
I have a list. I have to do some comparison of each item in the list with
each other items in the list.
from numpy import zeros
a=zeros((5,5))
myres=['R', 'N', 'L', 'C', 'M']
DON=['R','N','L'] ; ALL=['R','L','M','S']
for x in myres:
for y in myres:
if x in DON:
if y in ALL: a[res.index(x),res.index(y)] = 1
else: continue
But here the value of y changes sequentially. I want y to cycle through the
list something like the following. Is there any function to do such circular
iteration.
cycle 1 y's value should be 'N', 'L', 'C', 'M, 'R' index 1,2,3,4,0 of myres
cycle 2 y's value should be 'L', 'C', 'M, 'R', 'N' index 2,3,4,0,1 ,,
cycle 3 y's value should be 'C', 'M', 'R', 'N','L' index 3,4,0,1,2 ,,
Thank you,
Bala
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100524/1c00dc4e/attachment.html>
More information about the Tutor
mailing list