Concept
Shortcut Operators (+=, -=)
Typing `score = score + 10` is repetitive carpal tunnel fuel. Use shortcuts:
python
score += 10 # Same as score = score + 10
health -= 5 # Took 5 damage
ammo *= 2 # Doubled ammo!
# 20. Shortcut Operators (+=, -=) Typing `score = score + 10` is repetitive carpal tunnel fuel. Use shortcuts: ```python score += 10 # Same as score = score + 10 health -= 5 # Took 5 damage ammo *= 2 # Doubled ammo! ``` Note: Python does not have `++`. Typing `score++` will immediately crash.
Checkpoint
How do you add 1 to a variable `count` in Python?
Practice
Create `coins = 50`. Add `25` coins to it using `+=` and print the new total.
01
Tap code blocks below to assemble
Available Blocks