Python Nested Loops

Rumman Ansari   Software Engineer   2022-10-12   188 Share
☰ Table of Contents

Table of Content:


Python Nested Loops

A loop may contain another loop in its body, this inner loop is called nested loop. But in a nested loop, the inner loop must terminate before the outer loop.

for i in range(1,6):
    for j in range (1,i):
        print("*", end=" ")
    print()

* 
* * 
* * * 
* * * *