how to calculate average in list python by using whil loop

Solutions on MaxInterview for how to calculate average in list python by using whil loop by the best coders in the world

showing results for - "how to calculate average in list python by using whil loop"
María Alejandra
14 May 2016
1def avg(list):
2    s = 0
3    total = 0.0
4    while(s < len(list)):
5        total = total + list[s]
6        s = s+1
7    return total/len(list)
8ans = avg([1, 2, 3, 4, 5])
9print(ans)