+ 1
Hello guys some one help me explain this while loop x = 1 while x < 10: if x%2 == 0: print(str(x) + " is even")
I have failed to understand this
3 Réponses
+ 2
Ohh now i get it the code will make an infinite loop until when the condition remains true.
+ 3
There appears to be an error in your code. x does not appear to be incremented, resulting in an infinite loop.
I believe your code is supposed to: for numbers 1-10 (inclusive; interval [1, 10]), if x mod 2 is equal to zero (if x is even) print {x} is even.
+ 2
That makes an infinite loop. Did you miss something?