How to solve the following mathematical operation on a given number? : <p>I have tried to write a code in python which will accept a number of any number of digits like
abcde and will give the result as a-b+c-d+e.<strong><em>If the number is 5624 then result will be 5-6+2-4 ie -3</em></strong>.I would like to get the answer where my problem is and how to solve that problem modifying my code.</p>

<p><strong>I would like the method I have approached to it. No other method to solve the same problem.</strong> </p>

<pre><code>num=(input("enter a number"))
l=len(num)-1
p=l
num = int(num)
q=num
for x in range(0,l+1):
    q=q/10;
    r=q%10;
    a[p]=r
    p-=1
for y in range(0,l):
    if (y/2==0):
        sum=sum +a[y]
    else:
        sum=sum-a[y]
print(sum)
</code></pre>

<p><strong><em>It is giving me error saying my list assignment index is going out of range.</em></strong></p>
