print('Hello, welcome to your grade calculator.')
GradeCount=0
totalGrades=0.0
moreStudent='y'
while moreStudent=='y' or moreStudent=='Y':
grade=float(input('Enter a grade or a -1 to end: '))
while grade !=-1:
if grade>100 or grade<0:
print('Invalid input. Please enter a value between 1 and 100.')
elif grade>=90 and grade<=100:
print('You got an A. Thats awesome.')
elif grade>= 80 and grade<=89:
print('You got a B. Good job.')
elif grade>= 70 and grade<=79:
print('You got a C. Thats fine I guess.')
elif grade>=60 and grade<=69:
print ('You got a D. Not very good.')
elif grade<60:
print ('You got an F. You fail.')
totalGrades=totalGrades + grade
GradeCount=GradeCount + 1
grade=float(input('Enter the next grade or -1 to end: '))
moreStudent=input('Are you a new student and ready to enter your grades?
y or n: ')
print ('Class grade average:' , format(totalGrades/GradeCount, '.2f'))
print ('Number of grades entered:',GradeCount)
Basically, at the top where it validates the input, how can I prevent any invalid input from being included in the average below? Also, how can I add a running count of grades entered, and a running total of the grades?