This works.
a = [2,5,3,7,9,12]
def mean_list(x):
b = 0
for i in x:
b=b+i
c = b/len(x)
return c
print(mean_list(a))
but this doesn't work, even though I have declared my list as global. Why?
def mean_list(x):
global a
a = [2,5,3,7,9,12]
b = 0
for i in x:
b=b+i
c = b/len(x)
return c
print(mean_list(a))
Aucun commentaire:
Enregistrer un commentaire