Science Oxford Logo

Correcting Wrong Responses


With a small addition to the code you have already written, you can get the program to tell you the right answer if you get the answer wrong - this way you might learn the right answer for next time, or you can see how close you were!

Within your if statement, find the line of code that happens when the wrong answer is given, e.g. print("Wrong answer!")


You can add multiple things into a print statement, seperated by a comma. So we can write something like this:

print("Wrong answer! The answer is: ", answer)

Notice how answer isn't in speech marks. We're asking the program to tell us the answer to the question that it has just looked at in the quiz file, so it will always have the answer to the current question.


Try it out!