← Quiz: Python Loops: all 13 questions
Quiz: Python Loops · Question 12 of 13
A program must keep asking for a password until the user types the right one. Which loop fits best?
A program must keep asking for a password until the user types the right one. Which loop fits best?
- A.A for loop over range(10)
- B.A while loop, because the number of tries is not known in advance
- C.A nested for loop
- D.No loop is needed
Answer & explanation
Correct answer: A while loop, because the number of tries is not known in advance
for suits a known number of repetitions; while repeats until a condition changes.
Can you get the rest right without peeking?
Take the timed Quiz: Python Loops quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →