# # Compute the average of a collection of values entered by the user. # The user will enter 0 to indicate that no further values will be entered # and the average should be displayed. The 0 is not included in the # average. # # Initialize count to 0 and total to 0 count = 0 total = 0 # Read the first value from the user num = float(input("Enter a number (0 to quit): ")) # While the value read from the user is not equal to 0 while num != 0: # Add the value entered by the user to the total total = total + num # Count that another value was added to the total count = count + 1 # Read the next line from the user num = float(input("Enter a number (0 to quit): ")) if count != 0: # Compute the average average = total / count # Display the average print(f"The average of those values is {average}.") else: print("No values were entered.")