This is my while loop so far. I ask the user how many assignments they completed, which can only be between 1 and 10 (and graded out of 0 to 5).
However, if they answer anything below 10, I want the to code to automatically enter it as zero, instead of the user having to manually enter 0 for each assignment they have not completed.
Right now my code will ask the user to input a grade 10 times, but I only want to input grades based on the users answer of how many assignments they completed. So if they answered 7, the question would be presented 7 times, and three 0 marks would be automatically factored in to the average.
while True:
result = input("How many assignments did you complete? ")
if result.isdigit() and 0 <= int(result) <= 10:
break;
print ("Try a number between 1 and 10")
total = 0
gradeCount = 0
while gradeCount < 10:
grade = float(input('What was assignment score: '))
if grade < 0 or grade > 5:
print('It should be a number from 0 to 5')
else:
gradeCount += 1
total += grade
aaverage = total / 30 * 100
print('Average: ', aaverage)