I need to restrict this loop from using values greater than 101 and less than zero. The assignment is to make program that finds the average of test scores inputed. I can't figure out what to do, but i feel it's simple. thanks in advance

T = 0

GC = 0
grade = int(input("Enter a grade, 999 to stop: "))


while grade != 999:

    if grade < 0:
        int(input('Enter a grade that is greater than zero: '))
    elif grade > 101:
        int(input('Enter a grade that is less than 102: '))
    else:
        T = T + grade
        GC = GC + 1
        grade = int(input("Another grade: "))

if GC != 0:
    average = round(float(T)/GC,2)
    print("The number of scores:",  GC,'\n',
          'The average is', average)

999 can't stop your program because of

elif grade > 101:

Try using (but it still errors if a non-number/letter is entered)

grade = -1
while grade != 999:
    grade = int(input('Enter a grade that is greater than zero: '))
    if 0 <= grade < 101: 
        ## do calcs for a correct entry
    else:
        print "incorrect entry"

problem solved thx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.