Module 3
Common loop mistakes
Errors to watch out for.
Three common mistakes
Here are three mistakes that beginners often make with loops.
PythonThree common mistakes.
# Mistake 1: forgetting to update the variable # while count < 3: # print(count) infinite loop! # Mistake 2: wrong indentation # for i in range(3): # print(i) IndentationError # Mistake 3: off-by-one with range # range(3) gives 0, 1, 2 (not 3)
→
What causes an infinite loop?