Source Code
def sum_digit(x):
    sum = 0
    while(x>0):
        r = x%10
        sum +=r
        x = x//10
    if(sum<=9):
        return sum
        
    if(sum>9):
        return sum_digit(sum)

def sum_list(x):
    sum = 0
    for i in x:
        sum += i
    return sum
        


t  = int(input())

arr = [int(x) for x in input().split()]

y = sum_list(arr)
z = sum_digit(y)

print(z)

Copy
The Tale of a Generous Prince misterRoshi22
Python 3
50 ms
17.7 MB
Accepted