++ is not an operator. It is two + operators. The + operator is the identity operator, which does nothing. (Clarification: the + and - unary operators only work on numbers, but I presume that you wouldn't expect a hypothetical ++ operator to work on strings.)

++count

Parses as

+(+count)

Which translates to

count

You have to use the slightly longer += operator to do what you want to do:

count += 1

I suspect the ++ and -- operators were left out for consistency and simplicity. I don't know the exact argument Guido van Rossum gave for the decision, but I can imagine a few arguments:

  • Simpler parsing. Technically, parsing ++count is ambiguous, as it could be +, +, count (two unary + operators) just as easily as it could be ++, count (one unary ++ operator). It's not a significant syntactic ambiguity, but it does exist.
  • Simpler language. ++ is nothing more than a synonym for += 1. It was a shorthand invented because C compilers were stupid and didn't know how to optimize a += 1 into the inc instruction most computers have. In this day of optimizing compilers and bytecode interpreted languages, adding operators to a language to allow programmers to optimize their code is usually frowned upon, especially in a language like Python that is designed to be consistent and readable.
  • Confusing side-effects. One common newbie error in languages with ++ operators is mixing up the differences (both in precedence and in return value) between the pre- and post-increment/decrement operators, and Python likes to eliminate language "gotcha"-s. The precedence issues of pre-/post-increment in C are pretty hairy, and incredibly easy to mess up.
Answer from Chris Lutz on Stack Overflow
Top answer
1 of 11
1353

++ is not an operator. It is two + operators. The + operator is the identity operator, which does nothing. (Clarification: the + and - unary operators only work on numbers, but I presume that you wouldn't expect a hypothetical ++ operator to work on strings.)

++count

Parses as

+(+count)

Which translates to

count

You have to use the slightly longer += operator to do what you want to do:

count += 1

I suspect the ++ and -- operators were left out for consistency and simplicity. I don't know the exact argument Guido van Rossum gave for the decision, but I can imagine a few arguments:

  • Simpler parsing. Technically, parsing ++count is ambiguous, as it could be +, +, count (two unary + operators) just as easily as it could be ++, count (one unary ++ operator). It's not a significant syntactic ambiguity, but it does exist.
  • Simpler language. ++ is nothing more than a synonym for += 1. It was a shorthand invented because C compilers were stupid and didn't know how to optimize a += 1 into the inc instruction most computers have. In this day of optimizing compilers and bytecode interpreted languages, adding operators to a language to allow programmers to optimize their code is usually frowned upon, especially in a language like Python that is designed to be consistent and readable.
  • Confusing side-effects. One common newbie error in languages with ++ operators is mixing up the differences (both in precedence and in return value) between the pre- and post-increment/decrement operators, and Python likes to eliminate language "gotcha"-s. The precedence issues of pre-/post-increment in C are pretty hairy, and incredibly easy to mess up.
2 of 11
451

Python does not have pre and post increment operators.

In Python, integers are immutable. That is you can't change them. This is because the integer objects can be used under several names. Try this:

>>> b = 5
>>> a = 5
>>> id(a)
162334512
>>> id(b)
162334512
>>> a is b
True

a and b above are actually the same object. If you incremented a, you would also increment b. That's not what you want. So you have to reassign. Like this:

b = b + 1

Many C programmers who used python wanted an increment operator, but that operator would look like it incremented the object, while it actually reassigns it. Therefore the -= and += operators where added, to be shorter than the b = b + 1, while being clearer and more flexible than b++, so most people will increment with:

b += 1

Which will reassign b to b+1. That is not an increment operator, because it does not increment b, it reassigns it.

In short: Python behaves differently here, because it is not C, and is not a low level wrapper around machine code, but a high-level dynamic language, where increments don't make sense, and also are not as necessary as in C, where you use them every time you have a loop, for example.

🌐
GeeksforGeeks
geeksforgeeks.org › python › g-fact-21-increment-and-decrement-operators-in-python
Increment += and Decrement -= Assignment Operators in Python - GeeksforGeeks
... # Initializing a variable x = 5 # Incrementing the variable by 1 # Equivalent to x = x + 1 x += 1 # Displaying the result print("Incremented value:", x) ... We do not have a specific decrement operator in Python (like -- in some other ...
Published   April 30, 2024
🌐
CodeGym
codegym.cc › java blog › learning python › increment and decrement in python
Increment and Decrement in Python
November 11, 2024 - For example, a for loop with a negative step in range() can allow you to loop backwards. ... This loop prints numbers from 5 to 1, decrementing by 1 each time. And there you have it! Although Python doesn’t include ++ and -- operators, it offers plenty of straightforward ways to increment and decrement values.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-decrement-a-python-for-loop
How to Decrement a Python for Loop - GeeksforGeeks
July 23, 2025 - In this example, the range(4, -1, -1) function generates a sequence starting from 4 and decrementing by 1 until reaching -1 (exclusive). The for loop iterates over this sequence, printing each value in reverse order.
🌐
LearnPython.com
learnpython.com › blog › decrement-in-python-for-loop
How to Decrement a Python for Loop | LearnPython.com
August 22, 2022 - We can also set the step parameter to some other value (like -3) and the for loop will decrement by 3 instead of 1. Let's modify the previous example and output the results: >>> for i in range(9, -1, -3): ... print(i) ... 9 6 3 0 · We can also define a list of elements and display them in reverse order based on the list length. If you don’t remember lists and other Python data structures, I encourage you to read more about the difference between lists, tuples, and dictionaries before you continue.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › perform for loop decrement in python
Perform For Loop Decrement in Python - Spark By {Examples}
May 31, 2024 - If you want to use range() with decrement for a loop in Python, you can set the step parameter to a negative value.
🌐
TutorialsPoint
tutorialspoint.com › increment-and-decrement-operators-in-python
Increment and Decrement Operators in Python?
August 23, 2023 - Python does not have unary increment/decrement operator (++/--). Instead to increment a value, use to decrement a value, use − Python does not provide multiple ways to do the same thing .
🌐
Scaler
scaler.com › home › topics › increment and decrement operators in python
Increment and Decrement Operators in Python - Scaler Topics
March 12, 2024 - In Python programming, simplicity is frequently associated with elegance. The Python Decrement Operator, denoted by -=, exemplifies this concept by offering a simple and expressive technique for reducing variables.
Find elsewhere
🌐
Runestone Academy
runestone.academy › ns › books › published › fopp › SimplePythonData › UpdatingVariables.html
2.13. Updating Variables — Foundations of Python Programming
If you try to update a variable ... x was initialized to 6. Updating a variable by adding something to it is called an increment; subtracting is called a decrement....
🌐
Python Pool
pythonpool.com › home › blog › 4 ways to decrement for loop in python
4 Ways to Decrement for loop in Python - Python Pool
January 3, 2024 - We will understand the concept of how to decrement the value in a for loop in Python and no that there is no decrement operator in Python
🌐
Invent with Python
inventwithpython.com › blog › pythons-fake-increment-and-decrement-operators.html
Python's Fake Increment and Decrement Operators - Invent with Python
May 21, 2018 - In Python, you can increase the value of a variable by 1 or reduce it by 1 using the augmented assignment operators. The code spam += 1 and spam -= 1 increments and decrements the numeric values in spam by 1, respectively.
🌐
Delft Stack
delftstack.com › home › howto › python › decrement a loop python
How to Decrement a Loop in Python | Delft Stack
March 11, 2025 - A decrementing loop is one that counts down from a specified number to a lower limit. This is particularly useful in scenarios where you need to reverse through a list or perform actions in a countdown format.
🌐
Python.org
discuss.python.org › ideas
Increment, decrement... Can we have inc(), dec() functions in Python? feature request :) - Page 2 - Ideas - Discussions on Python.org
December 4, 2022 - No. It is nothing like next. I’ve already given code using Python syntax that shows how Pascal inc and dec work. Unfortunately you can’t run that code, because they are don’t work in Python, but you can surely follow the input and the expected result. Let’s try again: x = 15 inc(x) # There is NO ASSIGNMENT HERE. assert x == 16 # But like magic, x has a new value!
🌐
Real Python
realpython.com › lessons › range-decrementing
Decrementing With range() (Video) – Real Python
Join us and get access to thousands of tutorials and a community of expert Pythonistas. ... You can supply a negative step value to generate a list of numbers that is decreasing. If you do that, you need to make sure your stopping value is less ...
Published   October 15, 2019
🌐
Llego
llego.dev › home › blog › a comprehensive guide to increment and decrement operators in python
A Comprehensive Guide to Increment and Decrement Operators in Python - llego.dev
May 9, 2023 - Increment and decrement operators are useful constructs in many programming languages that allow you to easily increment or decrement a variable by 1. Python supports two unary operators for this purpose - ++ and --. However, the behavior of these operators differs from languages like C, C++, or Java.
🌐
TechBeamers
techbeamers.com › python-increment-and-decrement-operators
Python Increment and Decrement Operations - TechBeamers
November 30, 2025 - Python does not support x--, but a value can be reduced using the -= operator. x = 10 x -= 1 # Equivalent to x = x - 1 print(x) # Output: 9 · Similar to incrementing, decrementing can be applied using a step value:
🌐
Squash
squash.io › how-to-use-increment-and-decrement-operators-in-python
How to Use Increment and Decrement Operators in Python
November 14, 2023 - Python supports the use of the += and -= operators to increment and decrement variables, respectively. These operators are shorthand notations that combine addition or subtraction with assignment.
🌐
Python Guides
pythonguides.com › increment-and-decrement-operators-in-python
Increment and Decrement Operators in Python
September 2, 2025 - This code shows how to decrease a variable’s value by 1 using the subtraction assignment operator (-=) in Python. Let’s see how to use the decrement operator with a string variable in Python.
🌐
iO Flood
ioflood.com › blog › python-increment-by-1-quick-and-easy-examples
Python Increment By 1 | Quick and Easy Examples
March 12, 2024 - For instance, if you have a variable x with a value of 5, you can increment it by 1 using x += 1. After this operation, x will hold a value of 6. Similarly, the -= operator is used to decrement a value.