I am getting the output for the program but not in the required way?
<p>Write a Python function that accepts a string as an input.
The function must return the sum of the digits 0-9 that appear in the string, ignoring all other characters.Return 0 if there are no digits in the string.</p>

<p>my code:</p>

<pre><code>user_string = raw_input("enter the string: ")
new_user_string = list(user_string)
addition_list = []
for s in new_user_string:
    if ( not s.isdigit()):
        combine_string = "".join(new_user_string)
        print ( combine_string)
    else:
        if ( s.isdigit()):
            addition_list.append(s)
            test = "".join(addition_list)
            output = sum(map(int,test))
            print ( output )
</code></pre>

<p>the output should be:</p>

<pre><code>Enter a string: aa11b33
8
</code></pre>

<p>my output:</p>

<pre><code>enter the string: aa11b33
aa11b33
aa11b33
1
2
aa11b33
5
8
</code></pre>

<p>Python cares about indentations:</p>

<pre><code>user_string = raw_input("enter the string: ")
new_user_string = list(user_string)
addition_list = []
for s in new_user_string:
    if ( not s.isdigit()):
        combine_string = "".join(new_user_string)
        #print ( combine_string)
    else:
        if ( s.isdigit()):
            addition_list.append(s)
            test = "".join(addition_list)
            output = sum(map(int,test))
print ( output )   #&lt;------ change here 
</code></pre>

<p>Also got rid of your inside print statement since it's not your output.</p>

python python-2.7 python-3.x ipython