workSpace/ALGORITHM
[Python] 평균 구하기
J o e
2020. 12. 20. 13:24
[나의 풀이]
def solution(arr):
return sum(arr)/len(arr)
[다른 풀이]
def average(list):
return (sum(list) / len(list))
def average(list):
if len(list) == 0:
return 0
return sum(list) / len(list)
from functools import reduce
def average(list):
return reduce(lambda x, y : x + y, list) / len(list)