Python Help finding value of i
What is the value of i at the end of the loop body when a is 6?
def loopIdentification():
i=0
for a in range(2,8):
开发者_如何转开发 i=i+a-3
return i
5
>>> def loopIdentification():
i=0
for a in range(2,8):
i=i+a-3
print a, i
return i
>>> loopIdentification()
2 -1
3 -1
4 0
5 2
6 5
7 9
9
精彩评论