Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
A for loop is a control flow statement that allows you to repeatedly execute a block of code for a specified number of times or until certain conditions are met.
Related terms
While Loop: A while loop repeatedly executes a block of code as long as a given condition remains true.
Loop Variable: The loop variable is a variable that keeps track of the current iteration or count in a loop.
Nested Loop: A nested loop is a loop inside another loop. It allows you to perform more complex repetitive tasks by iterating over multiple sets of data simultaneously.