Now let’s talk about loops in Python. To loop through a list of numbers, we just have to … range() function allows to increment the “loop index” in required amount of steps. It falls under the category of definite iteration. This is less like the for keyword in other programming languages, and works more like an iterator method as found in other object-orientated programming languages. Python provides a counter class that is the subclass of the collections modules. Create a Countdown. By using our site, you But have you ever wondered, what happens, if you try to increment the value of the iterator from inside the for loop. edit Python For Loops A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). code, The above example shows this odd behavior of the for loop because the for loop in Python is not a convention C style for loop, i.e., for (i=0; i