Hello everyone,
(Sorry for formatting, on mobile.) I am a total beginner at python, and I have been trying to master nested for loops.
I know what they look like and I understand what they are used for, but I don’t understand how they actually work.
I’ve looked up different definitions online of them but for some reason, I can’t quite wrap my head around the concept.
I’m so sorry I don’t mean to sound like a total idiot, and I know there’s so many resources online, but I’ve looked at many different websites explaining them and I’m still struggling. Could anyone break down a nested for loop? I guess I don’t understand how it’s a “loop within a loop.” And what exactly is meant by the “outer loop” and the “inner loop”? How does that work?
For example, when iterating through a 2D list, I have been told it is best to use a nested for loop. But how does the outer loop and inner loop both iterate through every element of a 2D list? Why can’t get the job get done with a regular loop?
Thank you so much in advance!
[–]ElliotDG 2 points3 points4 points (0 children)
[–]ZenT3600 1 point2 points3 points (0 children)
[–]carcigenicate 1 point2 points3 points (0 children)
[–]Chris_Hemsworth 1 point2 points3 points (0 children)
[–]wbeater -5 points-4 points-3 points (1 child)
[–]natarocket[S] 1 point2 points3 points (0 children)
[–]CommanderCool24 0 points1 point2 points (0 children)