25% off

Use code FUNCMAIN at checkout for 25% off all premium courses.

Get started →

Interactive Go · Lesson

Arrays & Slices

Adventurers need to carry their spoils. A slice is Go’s flexible, growable list. You can create one with a literal, index into it, and grow it with append:

party := []string{"Elara", "Aragorn"}
party = append(party, "Gimli")   // [Elara Aragorn Gimli]
fmt.Println(party[0])            // Elara

(An array has a fixed size, like [3]string{...}; a slice wraps an array and can grow — slices are what you’ll use almost all the time.)

Your Quest

Add "potion" to the backpack slice with append, then print the whole backpack.

Expected output:

[sword shield bow potion]

Hint

backpack = append(backpack, "potion")append returns the new slice, so assign it back. Then fmt.Println(backpack).

Additional Scrolls of Wisdom