0
Can someone please explain why this code does not work and how to fix it?
x = int(input()) y = int(input()) while x <= y: if x%2 == 0: print(str(x) + " is even.") else: print(str(x) + " is odd.") x += 1 Thank you guys. It works properly now. I'm learning how important indentation is. đČ
3 Answers
+ 1
Just indent the increment statement correctly in while loop.
x = int(input())
y = int(input())
while x <= y:
if x%2 == 0:
print(str(x) + " is even.")
else:
print(str(x) + " is odd.")
x += 1
0
add four spaces before x because it is not from the loop.