0
我不断收到此错误:的Python:IndexError:列表索引超出范围
line 4, in timesTwo
IndexError: list index out of range
对这一计划:
def timesTwo(myList):
counter = 0
while (counter <= len(myList)):
if myList[counter] > 0:
myList[counter] = myList[counter]*2
counter = counter + 1
elif (myList[counter] < 0):
myList[counter] = myList[counter]*2
counter = counter + 1
else:
myList[counter] = "zero"
return myList
我不完全知道如何修正这个错误。有任何想法吗?
完美。谢谢我的男人 – user1707398
@ user1707398没有概率,开心有帮助。 – RocketDonkey