- #1
late347
- 301
- 15
I was thinking about triple nested for loop with a simple thought exercise on my own. I was little bit confused about that third nested loop (print c loop)
With simple case of double nested loop, I think I understood how the program works. (only one nesting).
But I'm having some trouble imagining exactly what letters and how many of them will be printed in this exercise. I'm having trouble with following the logic of the triple nested loop.
In simple nested loop, with only two loops:
With simple case of double nested loop, I think I understood how the program works. (only one nesting).
But I'm having some trouble imagining exactly what letters and how many of them will be printed in this exercise. I'm having trouble with following the logic of the triple nested loop.
In simple nested loop, with only two loops:
- the first loop takes one step. Then the program proceeds to the second loop and fulfilles the entire second loop.
- And then it returns to the second step, of the first loop, then it proceeds to fulfill the entire second loop.
- And then the program returns to the third step of the first loop, then the program proceeds to fulfill the entire second loop.
Python:
for a in range(3):
print("a",end="")
for b in range(3):
print("b",end="")
for c in range(3):
print("c",end="")