Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Trim

This code compares a string with extra spaces to the word "hello", but the comparison fails because of the whitespace! Fix it by trimming the spaces before comparing.

Fix the code so it prints:

text
Match!

Hint: Use .trim() to remove the extra spaces from the beginning and end of the string before comparing.

rust
fn main() {
let input = " hello ";
if input == "hello" {
println!("Match!");
} else {
println!("No match!");
}
}