0

[Solved] Why does swapping lines 6 and 7 result in a different output?

https://code.sololearn.com/cTWdhpb8AVy2/?ref=app

7th Oct 2020, 5:51 PM
Adam Stork
Adam Stork - avatar
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!
7th Oct 2020, 6:35 PM
Adam Stork
Adam Stork - avatar
+ 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?
7th Oct 2020, 6:14 PM
Adam Stork
Adam Stork - avatar