Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 124
    I think that @Thomas's explanation is more useful here; I think the question is more of why and not what. Commented Apr 7, 2014 at 21:43
  • 1
    Agreed with @rickcnagy, more like the "how to do it?" (if you really don't care about brevity of code you could also simply do number = number + 1) the reasoning on why ++ and -- don't exist in Python seems more useful. Commented May 3, 2017 at 15:40
  • 8
    Not exactly. The following will not work as expected: progress = 0; print(progress += 1). So += does not seem to completely replace C++'s ++ operator. Commented Oct 12, 2018 at 18:07
  • Python has loads of ?= where ? is replaced by another operator, although it wont work with every operator. For example n \= 2 becomes n = n \ 2, however n +== 1 doesn't unpack to n = n += 1 Commented Feb 27, 2021 at 18:41