/* */ Click to Join Live Class with Shankar sir Call 9798158723

Python Nested for loop


it is possible to write one loop inside another loop for example we can write a for loop inside a while loop or a for loop inside another for loop , such loops are called nested loops

Syntax of python nested loop


forvar in sequence:
  forvar in sequence:

    statement


How for Loop Works

the first element of the sequence is assigned to the variable written after for and then the statements are executed nest the second element of the sequence is assigned to the variable and then the statement are executed second time. in theis way for each element of the sequence the statement are excuted onece so the for loop is executed as many time as there are number of elements in the sequence.

Note:- All statements and instructions in a program are built with tokens.