Python operator: ++

I often need to encode a simple 1 increment unit (++) in Python.

I have never found a better solution than

x = x + 1 

What am I doing wrong?

+4
source share
2 answers

Python does not have a ++ operator. You should use the += operator:

 x += 1 
+14
source

The answer you are looking for:

 x += 1 
+3
source

Source: https://habr.com/ru/post/1414951/


All Articles