An infinite loop is a loop that never exits. This can happen for a few reasons:

  1. The loop condition cannot possibly be false (e.g. while 1 != 2)

  2. The logic of the loop prevents the loop condition from becoming false.


count = 10 while count > 0: count += 1 # Instead of count -= 1



The loop in the editor has two problems: it’s missing a colon (a syntax error) and count is never incremented (logical error). The latter will result in an infinite loop, so be sure to fix both before running!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?