Converting a for loop to a while loop

前端 未结 5 1009
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 03:19

I am new to Python and I need to convert a for loop to a while loop and I am not sure how to do it. This is what I am working with:



        
5条回答
  •  时光说笑
    2020-12-12 04:13

    like this:

    def scrollList(myList):
          negativeIndices = []
          i = 0
          while i < len(myList):
                if myList[i] < 0:
                     negativeIndices.append(i)
                i += 1
          return negativeIndices
    

提交回复
热议问题