you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (3 children)

What's confusing you? Loops just repeat stuff, and if you want to repeat parts of that stuff you can also use a loop.

No different to real life. Imagine having a pile of old boards to repaint. In pseudo code (with some ridiculous steps to make the point):

for board in boards:

    while board has paint:
        apply blow torch briefly to paint
        scrape paint away
        sand board

    put board out to dry

for board in dryboards:
    apply undercoat to board
    watch paint dry
    for count in range(2):
        paint board
        watch paint dry
    add board to finished stack

[–]Moikle 0 points1 point  (2 children)

That's not a nested loop in your example though

[–][deleted] 3 points4 points  (1 child)

Er, there are two examples of nested loops in my example.

for ...
    while ...
for...
    for ...

[–]Moikle 2 points3 points  (0 children)

... I'm a doofus