Problem:


Sum of Numbers

  Write a program which reads an integer and prints 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 single zero. Your program should not process for this terminal symbol.

Output

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

Sample Input

123
55
1000
0

Sample Output

6
10
1



Sample input:
123
55
1000
0


Sample output:
6
10
1

Submission status: Runtime Error

Solution code:
    a = int(input())
    alist = []

    if a/1000 >=1:
        alist.append(int(a/1000))
    if (a-int(a/1000)*1000) / 100 >= 1:
        alist.append(int((a-int(a/1000)*1000) / 100))
    if (a-int(a/100)) / 10 >= 1:
        alist.append(int((a-(int(a/100)*100)) / 10))
    alist.append(a-(int(a/10)*10))
    a2 = 0
    for i in alist:
        a2 += i
    print(a2)

Submission status: Runtime Error

Solution code:
while 1 == 1:
    a = int(input())
    alist = []

    if a/1000 >=1:
        alist.append(int(a/1000))
    if (a-int(a/1000)*1000) / 100 >= 1:
        alist.append(int((a-int(a/1000)*1000) / 100))
    if (a-int(a/100)) / 10 >= 1:
        alist.append(int((a-(int(a/100)*100)) / 10))
    alist.append(a-(int(a/10)*10))
    a2 = 0
    for i in alist:
        a2 += i
    print(a2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
while True:
    num = input()
    ret = 0
    for i in num:
        ret += num
    print(num)

Submission status: Runtime Error

Solution code:
while True:
    num = input()
    ret = 0
    for i in num:
        ret += int(i)
    print(num)

Submission status: Runtime Error

Solution code:
while True:
    num = input()
    if(num == 0): break
    ret = 0
    for i in num:
        ret += int(i)
    print(ret)

Submission status: Runtime Error

Solution code:
while True:
    num = str(input())
    if(num == 0): break
    ret = 0
    for i in num:
        ret += int(i)
    print(ret)

Submission status: Runtime Error

Solution code:
x = map(input(int,list(x))
if 0 != x[0]:
    print sum(map(int,list(x)))

Submission status: Runtime Error

Solution code:
x = map(input(int,list(x))
if 0 != x[0]:
    print sum(x)

Submission status: Runtime Error

Solution code:
import math

while True :

x = int(input()) 

  if x == 0 :
    break 

  else :
    sum = 0 
    n=floor(log(x,10))
    sum = floor(x/pow(10,n))
    for i in reversed(xrange(n+1))
      sum = sum + floor((x%pow(10,i))/pow(10,i-1))

  print(sum)

Submission status: Runtime Error

Solution code:
import math

while True :

x = int(input()) 

  if x == 0 :
    break 

  else :
    sum = 0 
    n=floor(log(x,10))
    sum = floor(x/pow(10,n))
    for i in reversed(range(n+1))
      sum = sum + floor((x%pow(10,i))/pow(10,i-1))

  print(sum)

Submission status: Runtime Error

Solution code:
import math

while True :

x = int(input()) 

  if x == 0 :
    break 

  else :
    sum = 0 
    n=floor(log(x,10))
    sum = floor(x/pow(10,n))
    for i in reversed(xrange(n+1)):
      sum = sum + floor((x%pow(10,i))/pow(10,i-1))

  print(sum)

Submission status: Runtime Error

Solution code:
while True
  x = input()
  if x == 0 :
    break 

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

Submission status: Runtime Error

Solution code:
while True :
  x = input()
  if x == '0' :
    break 

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

  print(sum)

Submission status: Runtime Error

Solution code:
import sys
while True :
  x = input()
  if x == '0' :
    break 

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

  print(sum)

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	while(cin>>s,s!="0"){
		int sum=0;
		for(int i=0;i<s.size();i++) sum+=s[i]-'0';
	cout<<sum<<endl;
	}
	return 0;
}

Submission status: Runtime Error

Solution code:
while True:
    a=input()
    if a==0: break
    sum([int(i) for i in a])

Submission status: Runtime Error

Solution code:
while True:
    a=raw_input()
    if a==0: break
    sum([int(i) for i in a])

Submission status: Runtime Error

Solution code:
while True:
    num = input()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while True:
    x = list(input())
    if x == 0:
        break
    sum = 0
    for i in range(len(x)):
        sum += int(x[i])
    print(sum)

Submission status: Runtime Error

Solution code:
while 1:
	x=input()
	if x=='0':
		break
	print sum(map(int,x))

Submission status: Runtime Error

Solution code:
while True:
    data = input()
    if data[0] == '0':
        break

    print(sum([int(i) for i in data]))

for str in iter(input, "0"):
  print(sum(int(c) for c in str))

Submission status: Runtime Error

Solution code:
while True:
    data = int(input())
    if data == '0':
        break

    print(sum([str(i) for i in data]))

Submission status: Runtime Error

Solution code:
while True:
    data = int(input())
    if data == '0':
        break

    print([str[i] for i in data])

Submission status: Runtime Error

Solution code:
while True:
    data = int(input())
    if data == 0:
        break
        
    print(sum([int(i) for i in data]))

Submission status: Runtime Error

Solution code:
while True:
    data = int(input())
    if data == 0:
        break

    sum == 0
    while

Submission status: Runtime Error

Solution code:
while True:
    a = 0
    data = input()
    if data == 0:
        break
    a += data
print(a)

Submission status: Runtime Error

Solution code:
n = int(input())
tarou == 0
hanako == 0
for x in range(n):
    if hanako > tarou:
        hanako += 3
    elif tarou > hanako:
        tarou += 3
    else:
        tarou += 0
        hanako += 0
print("{0} {1}".format(tarou, hanako))

Submission status: Runtime Error

Solution code:
n = int(input())
tarou == 0
hanako == 0
for x in range(n):
    if hanako > tarou:
        hanako += 3
    elif tarou > hanako:
        tarou += 3
    else:
        tarou += 1
        hanako += 1
print("{0} {1}".format(tarou, hanako))

Submission status: Runtime Error

Solution code:
while 1:
    input = raw_input()
    num = len(input)
    input = int(input)

    count = 0
    for i in range(num, 0, -1):
        value = int(input / 10**(i-1))
        input -= value * 10 ** (i-1)
        count += value

    print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while 1:
 n = input()
 if int(n) == 0:
  break
 sum = 0
 for i in range(n):
  sum += int(i)
 print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while True:
    value = [int(x) for x in raw_input().split()]
    if value == 0:
        break
    print(sum(value))

Submission status: Runtime Error

Solution code:
while True:
  x = input()
  if x == 0:
    quit()

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

Submission status: Runtime Error

Solution code:
while 1:
    x = input()
    if x[0] == 0:
        break
    print (sum(int(i)for i in x
    ))

Submission status: Runtime Error

Solution code:
while 1:
    x = input()
    if x[0] == 0:
        break
    print (sum(int(i)for i in x))

Submission status: Runtime Error

Solution code:
while(1):
    word = input()
    if (word = "0"):
        break
    result = 0
    for i in word:
        result += int(i)
    print(result)

Submission status: Runtime Error

Solution code:
while True:
    count = 0
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    for n in num:
        count += n
    print(count)

Submission status: Runtime Error

Solution code:
while True:
    count = 0
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    for n in num:
        count += n
    print(count + "\n")

Submission status: Runtime Error

Solution code:
while True:
    count = 0
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    for n in num:
        count += n
    print(count, end ="\n")

Submission status: Runtime Error

Solution code:
while True:
    count = 0
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    for n in num:
        count += n
        print(count, end ="\n")

Submission status: Runtime Error

Solution code:
while True:
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    print(sum(num))

Submission status: Runtime Error

Solution code:
while True:
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    print(sum(num), end = "\n")

Submission status: Runtime Error

Solution code:
while True:
    x = input()
    if x == "0":
        break
    num = x.split("")
    print(sum(num))

Submission status: Runtime Error

Solution code:
while True:
    x = input()
    if x == "0":
        break
    num = [int(i) for i in x.split("")]
    print(str(sum(num)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while True:
    x = input()
    if x == "0":
        break
    num = [int(i) for i in x.split("")]
    print(sum(num), end = "\n")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while True:
    x = input()
    if x == "0":
        break
    ns = []
    for n in x:
    ns.append(int(n))
     
    print(sum(ns))

Submission status: Runtime Error

Solution code:
while True:
    x = input()
    if x == "0":
        break
    ns = []
    for n in x:
    ns.append(int(n))
    print(sum(ns))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while True:
  x=input()
  if x==0:
   break
  print(sum(int(z) for z in x))

Submission status: Runtime Error

Solution code:
list1 = []
while True:
    x = str(input())
    if x == '0':
        break
    else:
        for i in x:
            result += int(x[i])
            list1.append(result)
sum(list1)

Submission status: Runtime Error

Solution code:
list1 = []
while True:
    x = str(input())
    if x == '0':
        break
    else:
        for i in x:
            result += int(i)
            list1.append(result)
sum(list1)

Submission status: Runtime Error

Solution code:
a=0

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

Submission status: Runtime Error

Solution code:
a=0

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

Submission status: Runtime Error

Solution code:
a=0

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

Submission status: Runtime Error

Solution code:
while True:
    input = list(map(int,list(input())))
    if input == [0]:
        break
    else:
        print(sum(input))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while True:
    n=sum(map(int, list(input()))
    if n == 0:
        break
    print(n)

Submission status: Runtime Error

Solution code:
while True:
    n=sum(list(map(int, list(input())))
    if n == 0:
        break
    print(n)

Submission status: Runtime Error

Solution code:
while True:
    x = input()
    if x == 0:
        break
    sum = 0
    while x != 0:
        sum += x%10
        x = x//10

    print(sum)

Submission status: Runtime Error

Solution code:
# 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

Submission status: Runtime Error

Solution code:
        while 1:
            x=sum(map(int,list(input())))
            if x==0:break
            print(x)

Submission status: Runtime Error

Solution code:
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)))

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
True:
    input = raw_input()
    if input == '0': break
    print sum(map(int, input))

Submission status: Runtime Error

Solution code:
while(True):
    for i in input():
        x += int(i)
    print(x)

Submission status: Runtime Error

Solution code:
while(True):
    x = 0
    for i in input():
        x += int(i)
    print(x)

Submission status: Runtime Error

Solution code:
while 1:
    a = int(input())
    if a ==0:
    break
    a = str(a)
    if a =
    print([a[i] for i in range(len(a))])

Submission status: Runtime Error

Solution code:
while 1:
    a = int(input())
    if a ==0:
    break
    a = str(a)
    print([a[i] for i in range(len(a))])

Submission status: Runtime Error

Solution code:
while 1:
    a = int(input())
    if a ==0:
    break
    a = str(a)
    print([a[i] for i in range(len(a))])

Submission status: Runtime Error

Solution code:
while True:
    x=input()
    if x==0:
        break
    print(sum(int(s) for s in range(x)))

Submission status: Runtime Error

Solution code:
while True:
    x=input()
    if x==0:
        break
    print(sum(int(s) for s in x))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
print(sum([int(x[i]) for i in range(len(x))]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while True:
    x = int(raw_input())
    if x == 0:
        break
    sum = 0
    for i in range(len(x)):
        sum += x[i]
    print sum

Submission status: Runtime Error

Solution code:
while True:
    x = str(raw_input())
    if x == 0:
        break
    sum = 0
    for i in range(len(x)):
        sum += int(x[i])
    print sum

Submission status: Runtime Error

Solution code:
while 1:
    n = raw_input()
    if x == '0': break;
    print reduce(lambda x,y: x+int(y), n, 0)

Submission status: WA: Presentation Error

Solution code:
answer =[]
while True:
    date = int(input())
    if date == 0:
        break
    a = date//1000
    b = date//100
    c = date//10
    answer.append(a+(b-a*10)+(c-b*10)+(date-c*10))
for j in range(len(answer)):
    if j == len(answer)-1:
        print(answer[j],end ='')
    else:
        print(answer[j])