← Back to Python Course | Chapter 2: Input, Output & Operators | Lesson 11 of 16

Python Increment & Decrement

Python has no plus-plus or minus-minus; instead you add or subtract one using plus-equals or minus-equals. It is like adding one tally mark to a counter each time something happens.
Syntax
python
variable += 1  # increment
variable -= 1  # decrement

No ++ or -- in Python

Python deliberately has no ++ or -- operator — writing x++ is a syntax error, not a working statement with unexpected behavior. The idiomatic way to increase or decrease a variable is x += 1 or x -= 1 instead.

Example: No ++ or -- in Python

python
x = 5
# x++  # SyntaxError: invalid syntax
x += 1
print(x)

Incremental Addition

+= lets you add any amount, not just one, in a single step: score += 10 immediately updates score to reflect the new total without a separate addition and reassignment line.

Example: Incremental Addition

python
score = 0
score += 10  # add 10 to score in one step
print(score)

Decremental Subtraction

-= mirrors += for subtraction, commonly used to count down remaining attempts, lives, or retries by decreasing a variable by a fixed or computed amount each time.

Example: Decremental Subtraction

python
lives = 3
lives -= 1  # subtract 1 from lives in one step
print(lives)

Incrementing List Items

To update a value stored inside a list, first access it by index and then apply the compound operator directly to that indexed position, like scores[0] += 5, which reads and rewrites that single list slot in place.

Example: Incrementing List Items

python
scores = [10, 20, 30]
scores[0] += 5  # read and update the value at index 0 in place
print(scores)

Other Combined Assignments

The same compound pattern extends to multiplication and division — *= scales a variable up and /= scales it down — giving Python a consistent shorthand family for "apply this operation, then store the result back."

Example: Other Combined Assignments

python
value = 4
value *= 2  # scale value up
print(value)
value /= 4  # scale value down
print(value)
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Writing x++ or ++x, which is not valid increment syntax; ++x silently does nothing (two unary plus signs) and x++ is a SyntaxError; use x += 1.
  2. Mixing types when incrementing, such as count += "1" on an int, which raises TypeError.
  3. Modifying the loop variable in for i in range(n): i += 1, expecting it to skip iterations; range resets i every pass.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.