Question & Answer

If I am using the following condition in my program

If I am using the following condition in my program:

while True:

Which keyword should I use to make sure I don’t create an infinite loop?

Answer Options:

  • break
  • continue

1 Answer

Verified archive
Quizzma TeamNovember 18, 2024

Correct Answer:

  • break

Explanation: The break keyword is used to exit a loop immediately, which is necessary to prevent an infinite loop in a while True: statement. The continue keyword skips the rest of the current iteration and goes to the next iteration of the loop, which does not terminate the loop.