정수 n이 매개변수로 주어질 때 n의 각 자리 숫자의 합을 return하도록 solution 함수를 완성해주세요.
내 코드
def solution(n): sum = 0 length = len(str(n)) while length: sum = sum + n % 10 n = n // 10 length = length - 1 answer = sum return answer