Write a program that reads n digit number. after reading the number, compute and display the sum of odd positioned digits,multiply all even positioned digits and add the two numbers. I have attempteed this problem like this
a = input("Enter number")
s = 0
p = 1
n = 1
while a>0:
digit=a%10
if n%2 == 0:
p = p*digit
else:
s = s+digit a=a/10
n=n+1
print "The sum is",s
print "Product is",p
it works perfectly for even no of digits but for odd no of digits like for 234 it shows the sum as 6 and product 3 whereas it should have been sum=3 and product 8. i am sure there is something wrong with my n value. pls help