Posts

Showing posts with the label for loop

Loops in Python: For Loop

Image
Loops are used when one wants to repeat a set of commands several times (iterations). For example,when you want to apply a set of operations on elements of a list, by choosing one element at a time, you can use a python loop. There are two types of loops: For loop While loop For loop:  For loop is used when we want to run the set of commands for a known or defined number of times. Few of the ways in which we can use the "for loop" is as follows: for i in range(10):     print(i)