Pybites Logo Rust Platform

Variables and Mutability

Level: intro (score: 1)

🧠 Rust makes you think about mutability from the get-go — and that starts with variables.

In Python, you can reassign a variable anytime. In Rust? Hold your horses!

Rust variables are immutable by default, which means if you want to change a value, you need to explicitly make it mutable using mut.


✅ Your task:

Implement the double_counter function:

  • Create a mutable counter variable and set it to 1
  • Double it 5 times in a loop
  • Return the final result (should be 32)

This exercise introduces:

  • let vs let mut
  • basic for loops
  • working with numbers

⚠️ Don’t hardcode the result (we cannot test using ast like Python) — use a mutable variable and a loop with a range (0..5) to double the counter.