0
Mistake in tutorial?
The third exercise in the python 3 tutorial - while loops looks like this: âHow many numbers does this loop print? i = 5 while true: print(i) i - 1 = i if i <= 2: print(break) _â The correct answer for this Is supposedly 3, but since the loop is set to run while i equals 5, wouldnât it stop after the first cycle?
2 Answers
0
i is set to 5, then the loop runs until a break condition. It's while true, so is basically an infinite loop unless you break out of it.
= is an assignment, == is the comparison. You would need while i == 5 for the situation you describe
0
I see, thanks. This had me really confused...