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. đŸ˜Č

19th Apr 2022, 8:29 PM
Ava Alford
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
20th Apr 2022, 3:32 PM
Pavan Barve
Pavan Barve - avatar
0
add four spaces before x because it is not from the loop.
19th Apr 2022, 10:42 PM
Mohamed Ayaou