You are viewing a single comment's thread from:

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

in #da-learnpythonwithsteem7 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

Coin Marketplace

STEEM 0.18
TRX 0.24
JST 0.034
BTC 97502.54
ETH 2743.51
SBD 0.43