In [33]:
def mean(numbers):
if type(numbers) is list: #Checking if the input is a list or not.
len=0
sum=0
for x in numbers:
sum=sum+x
len=len+1
return sum/len
else:
print("Please re-enter the input in the form of a list and run the function again.")
In [34]:
l=[1,2,3,4,5]
In [35]:
mean(l)
Out[35]:
In [36]:
l=[-11,2,-3,4,5]
In [37]:
mean(l)
Out[37]:
In [38]:
l=1,2,3,4
In [39]:
mean(l)
In [ ]: