次のようなものを試してください:
a = int(input("Enter a number: "))
more = input("Please enter Y or N if you want to add more numbers: ")
summ=a #intialize sum to a
count=1 # no. of integers entered, to calculate mean
while more.lower()=="y":
b = int(input("Enter another number: "))
count+=1 #increase count by 1
summ+= b #add b to sum
abMean = summ/float(count) #used float(count) to get actual value
print("sum=",summ)
print("mean=",abMean)
more = input("Please enter Y or N if you want to add more numbers: ") #ask for user input
print("sum=",summ)
print("mean=",abMean)
出力:
Enter a number: 5
Please enter Y or N if you want to add more numbers: y
Enter another number: 5
sum= 10
mean= 5.0
Please enter Y or N if you want to add more numbers: y
Enter another number: 2
sum= 12
mean= 4.0
Please enter Y or N if you want to add more numbers: y
Enter another number: 15
sum= 27
mean= 6.75
Please enter Y or N if you want to add more numbers: y
Enter another number: 10
sum= 37
mean= 7.4
Please enter Y or N if you want to add more numbers: n
sum= 37
mean= 7.4