我想定义一个函数,它返回两个给定数字之间的所有整数的总和,但我在下面的最后一行代码中遇到了问题。例如,用户输入两个整数,例如(2,6),并且该函数将一起添加所有内容,2 + 3 + 4 + 5 + 6 = 20。我无法弄清楚如何使我的函数在输入(x)处开始并在输入(y)处结束。另外,我想使用while循环。虽然循环和元组
def gauss(x, y):
"""returns the sum of all the integers between, and including, the two given numbers
int, int -> int"""
x = int
y = int
counter = 1
while counter <= x:
return (x + counter: len(y))
我试着修复你的代码格式,但是'x = int'等没有意义 – 2015-02-09 04:34:34