Python has no pre/post increment/decrement operator. For instance, x++
and x--
will fail to parse. More importantly,
++x
and --x
will do nothing. To increment a number, simply write x += 1
.
Code examples
Noncompliant code example
++x # Noncompliant: pre and post increment operators do not exist in Python.
x-- # Noncompliant: pre and post decrement operators do not exist in Python.
Compliant solution
x += 1
x -= 1