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

tc = int(input())

num = 0
while(tc):
    x = int(input())
    num+= x
    tc-=1
    
while(num>9):
    num = sum_digit(num)
    
print(num)
Copy
The Tale of a Generous Prince misterRoshi22
Python 3
16 ms
2.8 MB
Runtime Error