In this video, you will learn the use of
for with else, nested for loop and range() function in Python.
For Loop with else:
In python, a for loop can have an optional else block as well.
The else block is executed if the items in the sequence used in for loop exhausts.
Syntax:
for var in sequence:
statement(s)
else:
statement(s)
Nested for loop:
The "inner loop" will be executed one time for each iteration of the "outer loop":
range() function in Python:
range() function has 2 prototype:
1. range(stop)
always starts from 0 to (stop-1).
2. range(start, stop, step)
We can also define the start, stop and step size. Step size defaults to 1 if not provided.
range(1,10) will generate numbers from 1 to 9 (10 numbers).
NOTE: range() function only accepts integer value
https://www.prowessapps.in/python
Write your queries at:
daneyallari@gmail.com
prowessapps.in@gmail.com
Please like, comment, share and subscribe.
Thank You
#daneyallari #python #pythonByDaneyalLari