Title: Sum of Numbers

Write a program that reads an integer and prints the sum of its digits.

Input:
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.

Output:
For each dataset, print the sum of digits in x.

Sample Input:
123
55
1000
0

Sample Output:
6
10
1

# Buggy version:
go = 1
while go == 1:
    a = str(input())
    alist = list(a)
    if a ==0:
        go = 0
        exit
    sum = 0
    for i in alist:
        i = int(i)
        sum += i
    if go == 1:
        print(sum)


# Fixed version:
go = 1
while go == 1:
    a = str(input())
    alist = list(a)
    if a == "0":
        go = 0
        exit
    sum = 0
    for i in alist:
        i = int(i)
        sum += i
    if go == 1:
        print(sum)

# Buggy version:
while True:
    num = input()
    if(num == 0): break
    ret = 0
    for i in num:
        ret += int(i)
    print(ret)


# Fixed version:
while True:
    num = input()
    if(num == "0"): break
    ret = 0
    for i in num:
        ret += int(i)
    print(ret)

# Buggy version:
import sys
from functools import reduce
for line in sys.stdin:
    if line == "0":
        break
    s = reduce(lambda a,b: int(a)+int(b), line.strip())
    print(s)

# Fixed version:
import sys
from functools import reduce
for line in sys.stdin:
    if int(line) == 0:
        break
    s = reduce(lambda a,b: int(a)+int(b), line.strip())
    print(s)

# Buggy version:
while 1:
    str = input()
    if(str == '0'): break
    print(sum([int(c) for c in list(input())]))

# Fixed version:
while 1:
    str = input()
    if(str == '0'): break
    print(sum([int(c) for c in list(str)]))

# Buggy version:
while True:
    data = int(input())
    if data == 0:
        break
        
    print(sum([int(i) for i in data]))

# Fixed version:
while True:
    data = input()
    if data == '0':
        break
 
    print(sum([int(i) for i in data]))

# Buggy version:
while True:
    n = list(map(int,input()))
    if n[0] ==0:
        break
    else:
        print(n.sum())


# Fixed version:
while True:
    n = []
    n = list(map(int, input()))
    if n == [0]:
        break
    print(sum(n))

# Buggy version:
while 1:
 n = input()
 if int(n) == 0:
  break
 sum = 0
 for i in range(n):
  sum += int(n[i])
 print(sum)

# Fixed version:
while 1:
 n = input()
 if int(n) == 0:
  break
 sum = 0
 for i in range(len(n)):
  sum += int(n[i])
 print(sum)

# Buggy version:
while True:
  x = input()
  if x == 0:
    quit()

  print(sum([int(_) for _ in str(x)]))

# Fixed version:
while True:
  x = input()
  if x == '0':
    quit()

  print(sum([int(_) for _ in x]))

# Buggy version:
n = input()
while n != "0":
    ans = 0
    for i in range(len(n)):
        print(ord(n[i:i+1]))
        ans += ord(n[i:i+1]) - 48

    print(ans)
    n = input()

# Fixed version:
n = input()
while n != "0":
    ans = 0
    for i in range(len(n)):
        ans += ord(n[i:i+1]) - 48

    print(ans)
    n = input()

# Buggy version:
while(1):
    word = input()
    if (word = "0"):
        break
    result = 0
    for i in word:
        result += int(i)
    print(result)
        

# Fixed version:
while(1):
    word = input()
    if (word == "0"):
        break
    result = 0
    for i in word:
        result += int(i)
    print(result)

# Buggy version:
while True:
    x = input()
    if x == "0":
        break
    num = [int(i) for i in x.split()]
    print(sum(num))

# Fixed version:
while True:
    x = input()
    if x == "0":
        break
    num = [int(i) for i in x]
    print(sum(num))

# Buggy version:
while 1:
    s = input()
    if s == '0':
        break
    print(sum(int(n)) for n in s)

# Fixed version:
while 1:
    s = input()
    if s == '0':break
    print(sum(int(n) for n in s))

# Buggy version:
x = 1
L=[]
n= 0
s=0
while x is not 0:
    x = int(input())
    L.append(x)
N=1
L.remove(0)
for i in L:
    while i >N:

        N=10*N
        n =i%N
        s+=(n/N*10)
        i-=n
    print (int(s))
    s=0
    N = 1

# Fixed version:
x = 1
L=[]
n= 0
s=0
while x is not 0:
    x = int(input())
    L.append(x)
N=1
L.remove(0)
for i in L:
    while i >=N:

        N=10*N
        n =i%N
        s+=(n/N*10)
        i-=n
    print (int(s))
    s=0
    N = 1

# Buggy version:
while True:
  x=input()
  if x==0:
   break
  print(sum(int(z) for z in x))

# Fixed version:
while True:
  x=input()
  if x == '0':
   break
  print(sum(int(z) for z in x))

# Buggy version:
list1 = []
result = 0
while True:
    x = str(input())
    if x == '0':
        break
    else:
        for i in x:
            result += int(i)
        list1.append(result)
            
for i in list1:
    print(i)

# Fixed version:
list1 = []
while True:
    x = str(input())
    if x == '0':
        break
    else:
        result=0
        for i in x:
            result += int(i)
        list1.append(result)
            
for i in list1:
    print(i)

# Buggy version:
a=0

while True:
    z=str(input())
    if z == 0 :
        break
    for i in z:
        k=int(i)
        a+=k
    print(a)
    a=0

# Fixed version:
a=0

while True:
    z=str(input())
    if z == '0' :
        break
    for i in z:
        k=int(i)
        a+=k
    print(a)
    a=0

# Buggy version:
while True:
    a = input()
    if a == "0":
        break
    print(sum([int(b) for b in list(a)])

# Fixed version:
while(True):
    a = input()
    if(a == '0'):
        break
    b = [int(i) for i in list(str(a))]
    print(sum(b))

# Buggy version:
while True:
    x = input()
    if x == 0:
        break
    sum = 0
    while x != 0:
        sum += x%10
        x = x//10

    print(sum)

# Fixed version:
while True:
    x = int(input())
    if x == 0:
        break
    sum = 0
    while x != 0:
        sum += x%10
        x = x//10

    print(sum)

# Buggy version:
def main():

    while True:
        number_string = input()
        if number_string == '0': break
        print(list(number_string))
        print(sum(map(int, list(number_string))))
    
main()

# Fixed version:
def main():

    while True:
        number_string = input()
        if number_string == '0': break
        print(sum(map(int, list(number_string))))
    
main()

# Buggy version:
# Belongs to : midandfeed aka asilentvoice
while(1):
	n = str(input())
	
	if n:
		ans = 0
		for x in n:
			ans += int(x)
		print(ans)
	else:
		break

# Fixed version:
# Belongs to : midandfeed aka asilentvoice
while(1):
	n = str(input())
	
	if n != '0':
		ans = 0
		for x in n:
			ans += int(x)
		print(ans)
	else:
		break

# Buggy version:
a = []
while True:
    n = int(input())
    if n == 0:
        break
    a.append(n)

for i in range(len(a)):
    b = list(str(a[i]))
    sum = 0
    for j in b:
        sum += int(j)
    print(sum)))

# Fixed version:
a = []
while True:
    n = int(input())
    if n == 0:
        break
    a.append(n)

for i in range(len(a)):
    b = list(str(a[i]))
    sum = 0
    for j in b:
        sum += int(j)
    print(sum)

# Buggy version:
while True:

    x = input()

    if x == 0:
        break

    length = len(x)
    tot = 0

    for i in range(length):
        tot += int(x[i:i + 1])
    print(tot)


# Fixed version:
while True:

    x = input()

    if x == '0':
        break

    length = len(x)
    tot = 0

    for i in range(length):
        tot += int(x[i:i + 1])
    print(tot)

# Buggy version:
from sys import stdin
for line in stdin:
    if line == '0':
        break
    num = list(map(int, line.strip('\n')))
    print(sum(num))


# Fixed version:
from sys import stdin
for line in stdin:
    if line == '0\n':
        break
    num = list(map(int, line.strip('\n')))
    print(sum(num))

# Buggy version:
while True:
   x=input()
   if x="0":
       break
   cnt = 0
   for i in x:
       num = int(i)
       cnt += num
   print(cnt)

# Fixed version:
while(True):
    num = input()
    if num == '0':
        break
    x = 0
    for i in num:
        x += int(i)
    print(x)

# Buggy version:
import sys

l = []
for i in sys.stdin:
    l.append(i)

for i in range(0,len(l)):
    if l[i] == '0':
        break
    count = 0
    for j in range(0,len(l[i])-1):
        count += int(l[i][j])
    print(count)


# Fixed version:
import sys

l = []
for i in sys.stdin:
    l.append(i)

for i in range(0,len(l)):
    if int(l[i]) == 0:
        break
    count = 0
    for j in range(0,len(l[i])-1):
        count += int(l[i][j])
    print(count)

# Buggy version:
while True:
    x=input()
    if x==0:
        break
    print(sum(int(s) for s in x))


# Fixed version:
while True:
    x=input()
    if x=='0':
        break
    print(sum(int(s) for s in x))

# Buggy version:
while True:
    n=input()
    if n==0:
        break
    s=list(n)
    a=[int(i) for i in s]
    print(sum(a))


# Fixed version:
while True:
    n=input()
    if n=='0':
        break
    s=list(n)
    a=[int(i) for i in s]
    print(sum(a))

# Buggy version:
while True:
    x = input()
    if x == 0:
        break
    print(sum(int(i) for i in x))



# Fixed version:
while True:
    x = input()
    if x == "0":
        break
    print(sum(int(i) for i in x))

# Buggy version:
while True:
    s = input()
    if s == "0":
        break
    a = 0
    for i in s:
        a += int(s[i])
    print(a)



# Fixed version:
while True:
  a = input()
  if a == "0":
    break
  s = 0
  for i in a:
    s += int(i)
  print(s)

# Buggy version:
while True:
    num = input()

    print sum(map(int,list(str(num))))
    if num == 0:
        break

# Fixed version:
while True:
    num = int(input())
    if num == 0:
        break
    print(sum(list(map(int, str(num)))))

# Buggy version:
while 1:
	x=input()
	if x=='0':
		break
	print sum(map(int,x))

# Fixed version:
while 1:
    x = input()
    if int(x) == 0:
        break
    print(sum(map(int,x)))

# Buggy version:
while True:
    input = list(map(int,list(input())))
    if input == [0]:
        break
    else:
        print(sum(input))

# Fixed version:
while True:
    n = list(map(int, str(input())))
    if n == [0]:
        break
    else:
        print(sum(n))

# Buggy version:
while True :
  x = input()
  if x == '0' :
    break 

  else:
   sum = 0 
   for i  in range(len(x)) :  
   sum += int(x[i])

  print(sum) 

# Fixed version:
while True:
    num=input()
    if num=='0':
        break
    else:
        sum=0
        for i in range(len(num)):
            sum+=int(num[i])
        print(sum)

# Buggy version:
while 1:
    x=[ int(i) for i in input()]
    if x==0:
        break
    print(sum(list(x)))

# Fixed version:
while 1:
    x = input()
    if x == '0':break
    print(sum([int(i) for i in x]))

# Buggy version:
while True:
    x = list(input())
    if x == "0":
        break
    sum = 0
    for i in range(len(x)):
        sum += int(x[i])
    print(sum)

# Fixed version:
while True:
    s = input()
    if s=="0":
        break
    x  = list(s)
    length = len(x)
    sum=0
    for i in range(length):
        sum+=int(x[i])
    print(sum)

# Buggy version:
while True:
    table=str(input())
    if table[0] == '0':
        break
    print(sum(int(num) for num in table(num)))



# Fixed version:
while True:
  table = str(input())
  if(table == '0'):
    break
  print(sum(int(num) for num in table))

# Buggy version:
while True:
    n=sum(list(map(int, list(input())))
    if n == 0:
        break
    print(n)

# Fixed version:
while True:
    n = input()
    if n == "0":
        break
    print(sum(map(int,list(n))))

# Buggy version:
while True:
    x = int(input())
    if x == 0:
        break
    sum = 0
    for i in range(len(x)):
        sum += x[i]
    print sum

# Fixed version:
while True:
  x = input()
  if int(x) == 0:
    break
  order_sum = 0
  for i in range(len(x)):
    order_sum += int(x[i])
  print(order_sum)