Question: I am getting an error message when my code is checked The call avg() returns None, not 0. I'm not sure why my code is

I am getting an error message when my code is checked

"The call avg() returns None, not 0." 

I'm not sure why my code is not returning 0 if there is nothing in the parameter?

def avg(*args): # The parameter is MISSING. Add it back. """ Returns average of all of arguments (passed via tuple expansion) Remember that the average of a list of arguments is the sum of all of the elements divided by the number of elements. Examples: avg(1.0, 2.0, 3.0) returns 2.0 avg(1.0, 1.0, 3.0, 5.0) returns 2.5 avg(1.0, 2.0, 3.0) returns 0 Parameter args: the function arguments Precondition: args are all numbers (int or float) """ vals = 0 for value in args: if args == (): return 0 if args != (): vals = vals + value mean = vals / len(args) return vals

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!