I was reading 'Starting Python' trying out in the shell some of the examples.
However, I get an error with this one. What am I doing wrong?
>>> def sum_average(*args):
size = len(args)
sum1 = sum(args)
average = sum1/float(size)
# return a tuple of three arguments
# args is the tuple we passed to the function
return args, sum1, average
>>> sum_average(1, 2, 3, 4, 5)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
sum_average(1, 2, 3, 4, 5)
File "<pyshell#2>", line 3, in sum_average
sum1 = sum(args)
File "<pyshell#14>", line 3, in sum
sum1 = sum(numbers)
[...]
File "<pyshell#14>", line 3, in sum
sum1 = sum(numbers)
File "<pyshell#14>", line 3, in sum
sum1 = sum(numbers)
RuntimeError: maximum recursion depth exceeded
Thanks.