0

guys, what’s wrong with this code? (python)

x = 0 while x <= 10: if x%2 == 0: print(x) x += 1

21st Nov 2020, 12:23 PM
Kluster Headache
3 odpowiedzi
+ 5
last line . put it in while block not in if block . delete 1 tab.
21st Nov 2020, 12:27 PM
[bool left=True;]
[bool left=True;] - avatar
+ 4
If the condition isn't evaluated to True. The x variable will not increment and it will end up in an infinite loop. It shoul be: x = 0 while x <= 10: if x % 2 == 0: print(x) x += 1 Much better way: for x in range(11): if x % 2 == 0: print(x)
21st Nov 2020, 12:29 PM
Nadie Fiind
Nadie Fiind - avatar
+ 2
thank u
21st Nov 2020, 12:28 PM
Kluster Headache