0

Python Quiz - Looping the answer and try again.

So for my homework I have to make a quiz in Python and I understand the basics but I want to know how I can loop back to the question if someone gets it wrong. For example: print("Question 1") print("What does CPU stand for?") print() print("a. Core- Processing Unit") print("b. Central Processing Unit") print("c. Control Processing Unit") if answer "c": print("Incorrect, try again.") How do I make it so it loops back to the question?

9th Oct 2016, 11:30 AM
Sam Jiji
Sam Jiji - avatar
1 Answer
+ 1
ans = input() while ans != "b": print("Incorrect, try again.") ans = input() or if you want to reprint the question as well: ans = "" while ans != "b": print("Question 1") ... ans = input() if ans != "b": print("Incorrect, try again.")
9th Oct 2016, 1:33 PM
Zen
Zen - avatar