If you were intending to test the number of iterations of each loop in a nested while loop and compare it with that of a for loop, I have just the program for that! Here you go:
#Nested while loop
i=5
j=5
count=0
count1=0
while i>0:
count+=1
print("\t\t",count,"OUTER LOOP")
while j>0:
count1+=1
print(count1,"INNER LOOP")
j-=1
i-=1
#Nested for loop
count=0
count1=0
for i in range(5):
count+=1
print("\t\t",count,"OUTER LOOP")
for j in range(5):
count1+=1
print(count1,"INNER LOOP")
I am attaching the output for your reference. This code was run on Python version 3.10
OUTPUT OF NESTED WHILE LOOP [OUTPUT OF NESTED FOR LOOP][2]
1: https://i.sstatic.net/ixM2k.png [2]: https://i.sstatic.net/1vsZp.png
EDIT: Nested while loops in Python works EXACTLY like nested for loops in Python.
I have edited my program in the following way:
#Nested while loop
i=5
j=5
count=0
count1=0
while i>0:
count+=1
print("\t\t",count,"OUTER LOOP")
while j>0:
count1+=1
print(count1,"INNER LOOP")
j-=1
break #Adding jump statement stops the iteration of inner loop and the outer loop gets executed again.
i-=1
OUTPUT OF EDITED WHILE LOOP PROGRAM