Question Detail
Question
Consider the code snippet:
i = 1; while i <= 5: print(i) # FORGOT i = i + 1!. What type of loop will this create?
Correct Answer
Option C is the correct answer.
Detailed Explanation
As indicated by the comment '# FORGOT i = i + 1!', the variable 'i' is never updated. Therefore, 'i' remains 1, the condition 'i <= 5' (1 <= 5) is always True, resulting in an infinite loop that continually prints 1.
Hint
The crucial part of avoiding an infinite loop is the 'update variable' step.