Back
+10 XP
Concept

Changing Variables

Variables aren't carved into granite. You can overwrite them anytime:

python
ammo = 10
ammo = 9     # Fired a shot!
print(ammo)  # Prints: 9

# 8. Changing Variables Variables aren't carved into granite. You can overwrite them anytime: ```python ammo = 10 ammo = 9 # Fired a shot! print(ammo) # Prints: 9 ``` Python rips the label `ammo` off the old number 10 and slaps it onto 9. The 10 evaporates into memory heaven.

Checkpoint

What prints when you run this? ```python x = 5 x = 20 print(x) ```

Practice

Create `gold = 100`, then update `gold = 250`, then print `gold`.

Terminal
01
Tap code blocks below to assemble
Available Blocks