

sum함수와 len함수를 이용해 list내의 평균값을 return하도록 만들었다.try, except구문으로 list내의 요소가 없을 때의 예외처리를 해주었다.# programmers, phase1 : 평균 구하기, python
def solution(arr):
try:
return sum(arr) / len(arr)
except ZeroDivisionError:
return 0


https://programmers.co.kr/learn/courses/30/lessons/12944
github