Here we are going to discuss, how to define a simple ‘for’ loop.
for num in range (10):
This is a simple ‘for’ loop which numbers from 0 to 9.
Here ‘num’ is variable, which is used in the ‘for’ loop.
‘in range’ is a key word which is used to define the number of iterations to be carried out in the ‘for’ loop.
when we compare with the ‘for’ loop statement in c++, we doesn’t need an Updation statement here.
Updation of the variable ‘num’ is carried out internally by our language.
And the statement inside the ‘for’ loop gets executed as long as the iteration of the ‘for’ loop continues.
And thus we obtain the following result.