Possible Duplicate:
Converting a for loop to a while loop
I have this for a for loop which I made I was wondering how I would write so it would work with a while loop.
def scrollList(myList):
negativeIndices=[]
for i in range(0,len(myList)):
if myList[i]<0:
negativeIndices.append(i)
return negativeIndices
So far I have this
def scrollList2(myList):
negativeIndices=[]
i= 0
length= len(myList)
while i != length:
if myList[i]<0:
negativeIndices.append(i)
i=i+1
return negativeIndices
[index for index, value in enumerate(myList) if value < 0])scrollList = lambda lst: [i for i,v in enumerate(lst) if v<0]for i in range(x): … x[i] …loops…