Simplified, your program could look like this:
abSum = int(raw_input("Enter a number: "))
while raw_input("Please enter Y if you want to add more numbers or anything else to finish: ") == 'Y':
b = int(raw_input("Enter another number: "))
abSum = abSum + b
abMean = abSum / 2
print(abSum)
print(abMean)
Basically you loop until user enters and empty line, or anything else in the second prompt, and then fix your sums/means.
You don't necessarily need a separate function for the task you're trying to accomplish. If you want a function for, say, a homework - then you can rewrite the piece to pass the value of b
to a separate function that will update the abSum
and abMean
and call that from within the while
loop.
Umm, and pardon me, my example doesn't actually calculate a mean, you need to count the number of entered values into, for instance, a third variable and then divide by that amount. Another answerer proposed a solution with a list of entered values that could work in your case.