0
guys, what’s wrong with this code? (python)
x = 0 while x <= 10: if x%2 == 0: print(x) x += 1
3 Respuestas
+ 5
last line . put it in while block not in if block . delete 1 tab.
+ 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)
+ 2
thank u