What are some common errors when creating loops?


#1

Question

What are some common errors when creating loops?

Answer

Loops can be tricky if you aren’t careful, and can end up crashing your program if they aren’t given conditions that can become False eventually. Some common issues are:

  1. Conditions that never possibly become False, causing infinite loops and crashing.
  2. Forgetting to put the colon : after the loop’s declaration.
  3. Not indenting code you want to run inside of a loop

FAQ: Learn Python- Loops - Change it up