The odd numbers in your example are 2 and 4. So 6 is correct.
The even number in your example is 3. So 3 is correct.
I would've probably did something like this:
def findproductandsum(userinput):
# Initialize counters.
finalproduct, finalsum = 1, 0
# Iterate over index and character in userinput.
for i, digitchar in enumerate(userinput):
# Convert digit character to integer
digit = int(digitchar)
# Position is i + 1 since the index is zero-based.
if (i + 1) % 2 == 0:
# Even.
finalproduct *= digit
else:
# Odd.
finalsum += digit
return finalproduct, finalsum
# Use 'raw_input' on Python 2 though, it's a good habit to get into.
n = input('Enter a number: ')
# findproductandsum returns a tuple, so unpack it into p and s.
p, s = findproductandsum(n)
print('n: {}, product: {}, sum: {}'.format(n, p, s))
You can check it using only evens (product):
assert(findproductandsum('01010101') == (1, 0))
and only odds (sum):
assert(findproductandsum('10101010') == (0, 4))