Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python帮助查找i的值_Python_Python 2.6 - Fatal编程技术网

Python帮助查找i的值

Python帮助查找i的值,python,python-2.6,Python,Python 2.6,当a为6时,循环体末端的i值是多少 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 >>> loopIde

当a为6时,循环体末端的i值是多少

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

为什么不试试那个代码并调用那个函数呢?非常感谢,我很感激。我只是用python做的,它给出了5.def sumlist(inputlist):listsum=0表示inputlist中的项:listsum=listsum+item return listsum#您对问题的描述(在注释中)如果这个答案解决了您的问题,您应该将其标记为正确答案:P