I am having problem with my python homework. My homework is asking to create a Python program to calculate a student test averages regardless of how many tests will be averaged. Also, it is asking to allow the teacher to continue averaging grades for any number of students. This is what I have so far. My problem the second part is not calculating right, what I'm I missing:

```````I

#First Step. (Similar example pg. 104)
count = 0
while moreGrades != "n":
grade = int(input("Enter a test grade: "))
moreGrades = input("Are there amy more test grades to enter, 'y' or 'n' ")
count = count + 1

print("The average is", round(average, 1))

#Second Step

plusStudents = "y"
plusStudents = input("Are there any more students, 'y' or 'n'? ")
while plusStudents != "n":
grade = int(input("Enter a test grade: "))
moreGrades = input("Are there amy more test grades to enter, 'y' or 'n' ")
count = count + 1

print("The average is", round(average, 1))
``````

The problem is that you aren't resetting either `count` or `totalGrade` before beginning the second loop. also, in both loops, you can (and probably should) move the calculation of `average` out of the loop body.

I think you'll also have a problem with the second loop's end condition, as you aren't changing `plusStudents` anywhere in the loop.

Mind you, there are ways to avoid having to have two otherwise identical loops one right after another. Has your course covered functions yet? For that matter, are you certain that these should be separate loops, as you have it here? I suspect that what you want is to nest the loops, with the outer loop being the test for whether to add more students, and the inner loop being the one to read in the test grades.

hmmm..okay I must be doing something wrong..it is all jacked up now

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.