0
[Solved] Why does swapping lines 6 and 7 result in a different output?
2 Réponses
+ 3
Jan Markus Got it. It was probably a redundant question on my part but I just wanted to make sure I understand 100%. Thank you, Jan! You guys are awesome!
+ 1
Jan Markus So lines 6 and 7 (and 16 and 17) will run indefinitely in a loop, until the if condition is met? I.e. like this:
print(a): 0
a += 1: 1
a == 5: False, so loop starts again from the beginning (Line 6).
print(a): 1
a += 1: 2
a == 5: False, so loop starts again from the beginning (Line 6).
print(a): 2
a += 1: 3
a == 5: False, so loop starts again from the beginning (Line 6).
print(a): 3
a += 1: 4
a == 5: False, so loop starts again from the beginning (Line 6).
print(a): 4
a += 1: 5
a == 5: True, so loop breaks.
Is this how loops work?