Question: Write a python program using a "While" loop that will ask for the user to input exam scores. You should start by asking the user how many scores they would like to enter. Then use a loop to request each score and add it to a total. Finally, calculate and display the average for entered scores.
The current code I have got is listed below though whenever I try to run it to see if it works, is comes up with Syntax Error: Invalid Syntax on the else.
I tried without else inside and outside the while loop and it came up with SyntaxErorr: Invalid Syntax. Perhaps you forgot a comma?
examNum = examCount
examCount = int(input("How many scores would you like to enter?"))
totalExam = (examCount + 1)
totalScore = sum(examScore)
while examNum < examCount:
examScore = int(input("Input your exam score."))
else:
print("Your average score is" totalScore)
Note: This is my first time doing Python in 5 – 10 years so I am back to square one with figuring everything else. I’m sure there is a obvious and easy work around but I’d appreciate any help.
>Solution :
Try this one:
examCount = int(input("How many scores would you like to enter?"))
exams = examCount
totalScore = 0
while examCount > 0:
examScore = int(input("Input your exam score."))
examCount -= 1
totalScore += examScore
print(totalScore/exams)