Exerpad
🔥 0
0 XP
Exercise 5 · Chapter: StringsRequired+50 XP

Replace Word

Start with the sentence "I like cats" and replace "cats" with "dogs". Print the new sentence.

Expected output:

I like dogs

Hints:

  • Use .replace("old", "new") to swap text
  • .replace() gives you a new string — print that!
rust
fn main() {
}
Output
Run your code to see the output here.