You are viewing a single comment's thread from:

RE: [DA series - Learn Python with Steem #06] 函式

in #da-learnpythonwithsteem6 years ago (edited)

Here's mine with nothing fancy: def my_average(listin): count, tot= 0, 0 for i in listin: count=count+1 tot=tot+i average = tot/count return(average) my_list = [1,8,3,6,2,345,-23,7] answer = my_average(my_list) print(answer) Result: 43.625