Python Assignment & Shorthand Operators
In programming, you frequently update a variable based on its existing value (like adding points to a score: score = score + 10). Python provides shorthand operators like += and -= so you do not have to repeat the variable name twice.
"Imagine a scoreboard at a basketball game. When someone scores, the referee does not say "new score equals old score plus two". They just say "+2 points!". That is what += 2 does."
Deep Dive: How It Works
Shorthand operators combine an arithmetic operation with assignment:
x += 5 is identical to x = x + 5 (increments x by 5).
x -= 3 is identical to x = x - 3 (decrements x by 3).
x *= 2 is identical to x = x * 2 (doubles x).
x /= 2 is identical to x = x / 2 (halves x).
Syntax Blueprint
score += 10 # Same as: score = score + 10 health -= 5 # Same as: health = health - 5 bonus *= 2 # Same as: bonus = bonus * 2
Place the math operator right before the equal sign to modify the variable in place.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Using =+ instead of +=Why it happens: Writing x =+ 5 sets x to positive 5 instead of adding 5 to it.
How to fix: Remember: math symbol comes FIRST, then equal sign (+=, -=, *=).
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Update balance with +=
Start with balance = 50.
Add 25 to balance using the += operator.
Print the updated balance.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.