It's New Year, and every pet is a year older. Add 1 to the Age of each pet in pets; the loop below shows the new ages. Careful: the p in for _, p := range pets is a copy, so changing it doesn't change the slice.
Bean 3 Tofu 6 Rex 10
package main
import "fmt"
type Pet struct {
Name string
Age int
}
func main() {
pets := []Pet{{"Bean", 2}, {"Tofu", 5}, {"Rex", 9}}
// your code here: with for i := range pets, add 1 to each Age
for _, p := range pets {
fmt.Println(p.Name, p.Age)
}
}
Run tries the examples. When they look right, Submit.