AI engineering glossary · Python core
What is while loop?
while loop: A loop that keeps running its block as long as a condition stays true, checking the condition before each pass. It suits cases where the number of repetitions is unknown in advance. The body must change something so the condition eventually becomes false.
while loop: an example
n = 3; while n > 0: print(n); n -= 1 prints 3, 2, 1 and stops.
Related terms
More Python core terms
Where you learn it
while loop is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.