Exerpad
🔥 0
0 XP
Exercise 2 · Chapter: VectorsRequired+50 XP

Add to List

Start with a vector containing "cat" and "dog". Then push "fish" onto the end. Print all 3 animals, one per line.

Expected output:

cat
dog
fish

Hints:

  • Create the vector with let mut pets = vec!["cat", "dog"];
  • Use .push("fish") to add the third item
  • Loop through the vector to print each animal
rust
fn main() {
}
Output
Run your code to see the output here.