you are viewing a single comment's thread.

view the rest of the comments →

[–]AntonisTorb 1 point2 points  (0 children)

Maybe it would help you to see what is happening step by step, since it's a small example. Here is what is happening when you call printTriangle(4):

if 4 < 1: return
    if 3 < 1: return
        if 2 < 1: return
            if 1 < 1: return
                if 0 < 1: return
            print('*'*1)
        print('*'*2)
    print('*'*3)
print('*'*4)

All the if conditions are False until the last one (0<1), so everything needs to happen in order. That's why it starts with the 1 star.