Call run_quiz

Replace the while loop body with a single run_quiz() call

💻

Writing code and entering commands is only available on desktop. Open this page on a larger screen to complete this chapter.

run_quiz now holds everything that makes up one quiz round. The while loop still has the old expanded body — nine lines doing exactly what one call can do.

Replacing those nine lines with run_quiz() makes the loop's purpose clear at a glance:

while True:
    run_quiz()
    print()
    again = input("Play again? (y/n): ")
    if again != "y":
        break

The loop no longer describes *how* a round works — it just says run the quiz, then ask whether to play again. The details live inside run_quiz where they belong.

Instructions

Replace the while loop body with a single call to run_quiz.

  1. In the while True: loop, replace everything from score = 0 through show_results(score, len(QUESTIONS)) with a single call: run_quiz() — one call now runs an entire quiz round, and the loop only needs to handle the play-again prompt.