Exerpad
🔥 0
0 XP
Exercise 5 · Chapter: For LoopsRequired+50 XP

Letter Counter

Count the number of letters (not spaces) in the string "hello world" and print the result.

Expected output:

Letters: 10

Hints:

  • Use for ch in "hello world".chars() to loop through each character
  • Use if ch != ' ' to skip spaces
  • Keep a let mut count = 0; and add 1 for each non-space character
rust
fn main() {
}
Output
Run your code to see the output here.