If I am using the following condition in my program:
Which keyword should I use to make sure I don’t create an infinite loop?
Answer Options:
- break
- continue
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Correct Answer:
Explanation: The
break
keyword is used to exit a loop immediately, which is necessary to prevent an infinite loop in awhile True:
statement. Thecontinue
keyword skips the rest of the current iteration and goes to the next iteration of the loop, which does not terminate the loop.