Rust Fundamentals · 10 XP

Variables and mutability

let binds a value to a name. Bindings are immutable by default: once set, they cannot change. That makes code easier to reason about, and the compiler will stop you if you try.

let apples = 3;
// apples = 4; // error: cannot assign twice to immutable variable

When you do need to change a value, opt in with mut:

let mut score = 0;
score += 10;

Your task

Finish total_score so it starts a mutable score at 0, adds points to it rounds times using a loop, and returns it.

Next lesson →

Sign in to run your code. It's free.