Python integer incrementing with ++

Znarkus picture Znarkus · Apr 13, 2010 · Viewed 1.2M times · Source

I've always laughed to myself when I've looked back at my VB6 days and thought, "What modern language doesn't allow incrementing with double plus signs?":

number++

To my surprise, I can't find anything about this in the Python docs. Must I really subject myself to number = number + 1? Don't people use the ++/-- notation?

Answer

Daniel Stutzbach picture Daniel Stutzbach · Apr 13, 2010

Python doesn't support ++, but you can do:

number += 1