# Arup Guha
# 9/16/2019
# Test scores example to illustrate continue and break.

def main():

    # Prompt the user.
    print("Please enter test scores, 1 per line, terminating your list with -1.")

    # Initial values for sum of test scores and # of valid tests.
    total = 0
    numtests = 0

    # We will do the loop control elsewhere.
    while True:

        # Read in the score.
        score = int(input(""))

        # Check breaking condition.
        if score == -1:
            break

        # This score just won't count.
        if score < 0 or score > 100:
            continue

        # Update our accumulators since this score is valid.
        total += score
        numtests += 1

    # Special case no tests, avoids division by 0.
    if numtests == 0:
        print("Sorry there are no valid tests to average.")

    # Regular case, output test average.
    else:
        print("The average score was",total/numtests)

main()
