Loop calculations in Python

This question already has an answer here:

  • How do you return multiple values in Python? 13 answers

  • A return statement (if present) is the last statement that gets executed in a function. So, as soon as it returns the value for the female category, the control exits the function. Since your return statement is inside the for loop, the next category doesn't get processed. You can move the return outside the for loop and have a list to store each value your want to return.

    链接地址: http://www.djcxy.com/p/53132.html

    上一篇: 如何从* args返回多个值?

    下一篇: 在Python中循环计算