Thank you for taking the time to check out my first post here. I have been learning Python for a couple of weeks now through Codecademy and earlier today I decided to create a very, very basic program similar to the game show Who Wants to be a Millionaire. I chose to make the questions all related to a video game series I love. The program runs fine despite being incredibly rudimentary. There are lots of sleep pauses for “dramatic effect.” It does not offer lifelines or anything like that. It’s basically just a quiz.
I am having some difficulty understanding how to make the program end when the individual playing answers a question incorrectly. Currently, the program functions through all 15 questions. It prints a message to the user telling them when they answer correctly or incorrectly. However, it then proceeds onto the next question. What is the best way to have the program stop when the user answers incorrectly? Below is an example of how the code looks for each question:
# First question print("For $100:") print("Bloodborne released on which platform in which year?\n") print("A. PC, 2016") print("B. PlayStation 4, 2015") print("C. Xbox One, PlayStation 4, and PC, 2015") print("D. PlayStation 3, 2014\n") answer1 = "B" answer1 = str(input("Your guess: ")) time.sleep(1.2) if answer1 == "B" or answer1 == "b": print("\nCorrect!") else: print("\nI'm sorry, that is the wrong answer. You lose!") time.sleep(0.6) print("Onto the next question...") time.sleep(0.6)
Thank you again for your time, and I appreciate any and all help! Take care!