Can I put a loop inside another loop?

Asked by emeka_nwankwo · 6 months ago

1 Answer

46
amorebise · 6 months ago Top Answer

Yes, we call that a Nested Loop. Think of a clock: the minute hand goes around 60 times (inner loop) for every 1 time the hour hand moves (outer loop).

They are powerful but can be slow if you aren't careful. If you have 100 items and put another 100-item loop inside, you are doing 10,000 tasks! Always be mindful of your computer's speed.

Log in to add a comment.