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

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 67100.18
ETH 2610.66
USDT 1.00
SBD 2.67