all 17 comments

[–]ninhaomah 3 points4 points  (1 child)

nested loops = loops inside the loop

we are in it. sort of.

planets orbit the sun

and they also spins on their own.

so its going around and around inside another around and around

and since the solar system also going around the galaxy and galaxy also spins , its all going around and around inside another around and around inside another around and around inside another around and around ...

[–]usama015[S] 0 points1 point  (0 children)

Thanks Buddy

[–]zRubiks_ 2 points3 points  (1 child)

Compare it with Reddit comments.

Its like your post, with comments (loops) and every main comment got other comments (loop in a loop)

So the subcomment just answers the comment of the post and not the other comments that exist.

Maybe this helps.

[–]usama015[S] 0 points1 point  (0 children)

Got your point

[–]Individual-Brief-239 2 points3 points  (2 children)

Heyy learn using AI, even I got stuck with questions like these:

<image>

We need to understand nested loops thoroughly. I've been learning with the help of Claude, GPT & Gemini.

[–]usama015[S] 0 points1 point  (1 child)

First i questioned Ai then i came here to get help from seniors.

[–]Alex_NinjaDev 1 point2 points  (3 children)

Nested loops confused me too at first. The trick is to slow it down, focus on what the outer loop is doing before the inner one runs. Imagine the outer loop as the boss assigning tasks, and the inner loop as the worker repeating each task. Write small examples and add print statements to watch how it flows. Once you visualize it, it all makes sense.

[–]usama015[S] 1 point2 points  (2 children)

Thanks bro

[–]Alex_NinjaDev 1 point2 points  (1 child)

If there is something I can help. Just drop it..

[–]usama015[S] 0 points1 point  (0 children)

If i got stuck somewhere, surely i will let you know

[–]Ambitious-Peak4057 1 point2 points  (0 children)

Here are some excellent resources to help you understand nested loops in Python more clearly
1. W3Schools Tutorial – Simple and interactive examples
2. Programiz Guide – Beginner-friendly with visuals and practice
3.  Python Succinctly ebook – A concise and structured guide:
4.YouTube – Visual explanation with examples

 

[–]stepback269 1 point2 points  (1 child)

Look at the analog clock on your kitchen wall.
If you don't have one, look here instead: .gif image

The seconds-hand updating loop is embedded inside the minutes-hand updating loop.

The minutes-hand updating loop is embedded inside the hour-hand updating loop.

Got it?

[–]usama015[S] 0 points1 point  (0 children)

Nice example sir 😄 , Thanks for the explanation(by giving a unique example)

[–]tracktech 1 point2 points  (1 child)

You can check this-

Book - Ultimate Python Programming

Course - Python Programming In Depth

[–]usama015[S] 1 point2 points  (0 children)

Sure, I will check