For Loop. The for statement is used to iterate over the elements of a sequence. It's traditionally used when you have a piece of code which you want to repeat n number of time. The for loop is often distinguished by an explicit loop counter or loop variable.