🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.A for loop over range(10)
  2. B.A while loop, because the number of tries is not known in advance
  3. C.A nested for loop
  4. 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 →