Aug-12-2018, 09:04 AM
Hi guys, I have an exercise question from a book. I can't figure out where and how do I place error message if the first input from the user is 0.
P.S - To quit the loop, user must enter 0 according to the exercise question so cant use string to break it.
Thank you for any reply in helping out.
P.S - To quit the loop, user must enter 0 according to the exercise question so cant use string to break it.
Thank you for any reply in helping out.
total = 0 counter = 0 while True: values = int(input("Enter the integer : ")) if values == 0: break total += values counter += 1 average = total / counter print('The average of the numbers entered is %d' %average)