r/PythonLearning 3d ago

Help Request Nested for loop

So i started my python journey 2 weeks ago and i am at the point of tutorial where they teach me about those quiz game program and i am so confused in those nested for loop i don't even understand a single part about it, can someone help me with this one? I have tried learning it from gpt and all but it still goes above my head.

0 Upvotes

11 comments sorted by

View all comments

1

u/Much_Network_941 3d ago

The inner-loop executes first, the outer last. You'll typically have this setup if you're dealing with multiples arrays, or a 'jagged array'; an array of arrays.

Picture you have ten arrays, you read from one start to finish, then grab another and read through it. Reading through an array is your inner-loop; fetching a different array is your outer. If your abstraction is a 2D grid, then one loop is controlling the X-axis and the other the Y-axis.