An alternative method to accomplish the same result would test whether the current item in the tuple is even (using if not num % 2:) and, if true, would add the current item to the running total.
实现相同结果的另一种方法是测试tuple中的当前项是否是偶数(使用if not num % 2:),如果为真,那么将当前项添加到运行总和中。
If I'm inside this FOR, OK, and I'm running around, if I ever hit a place where this test is true, I'm going to execute that return, return that return returns from the entire procedure.
如果我是在这个for循环里面,我正在运行,如果我运行到test的值为真的地方,我就会执行,这个return将会返回整个程序的值,明白了吗?
So what's going to happen here? If I'm inside this FOR, OK, and I'm running around, if I ever hit a place where this test is true, I'm going to execute that return, return that return returns from the entire procedure. OK? So the return comes back from the procedure.
那么这里发生了什么呢?,如果我是在这个for循环里面,我正在运行,如果我运行到test的值为真的地方,我就会执行,这个return将会返回整个程序的值,明白了吗?所以它将会从整个程序中返回值。
应用推荐