+ 2
Help me please!
Hello, I'm beginner. what does this mean x += 1 ? x = 1 while x < 10: if x%2 == 0: print(str(x) + " is even") else: print(str(x) + " is odd") x += 1
9 Answers
+ 4
Jayakrishnađźđł you're absolutely correct. I missed the fact that the question was about Python code. Thanks.
+ 2
Short form of x=x+1 is x+=1.
Using there in loop to increment x value from x=1 to x=10
When x<10 becomes false ,loop gets terminated...
+ 2
Another way to write it is x++
0
In this code, u are separating the numbers into odds and evens between 1-10.
U have initially started from 1 and the code checks are less than 10 or not then continues.
x+=1 represents increment the number to one as x=1, the next number would be 2.
You can also use x++ if u are confusing with that.