There are actually two ways you can do this. One is to use the increment operator ++ and decrement operator –. For example, the statement “x++” means to increment the value of x by 1. Likewise, the statement “x –” means to decrement the value of x by 1. Another way of writing increment statements is to use the conventional + plus sign or – minus sign. In the case of “x++”, another way to write it is “x = x +1″.
Lets take a variable int A; different ways to write : A += 1; A++; A = A + 1;
Here is few example for the same.
int a; a++; (post increment) a--; (post decrement) ++a; (pre increment) --a; (pre decrement)
Which one will be faster in Java, Increment operator or Decrement operator?
a) for(int i = 0; i < 1000; i++) {} b) for(int i = 1000; i > 0; i--) {}
I'm a relative newbie to python, and this NG, but it's certainly growing on me.
One thing I'm missing is the increment/decrement operator from C, ie x++, and its ilk. Likewise x += y.
Is there any way of doing this in Python?