Complete the code to create a slice of integers with length 3.
numbers := make([]int, [1])The make function creates a slice with the specified length. Here, length 3 means the slice has 3 elements.
Complete the code to append the value 7 to the slice named nums.
nums = append(nums, [1])The append function adds the given value to the end of the slice. Here, we add 7.
Fix the error in the code to get the first element of the slice data.
first := data[1]In Go, to access an element of a slice, use square brackets with the index inside, like data[0].
Fill both blanks to create a new slice sub that contains elements from index 1 to 3 (exclusive) of items.
sub := items[[1]:[2]]
Slicing in Go uses the syntax slice[start:end]. The slice includes elements from start up to but not including end. To get elements at indexes 1 and 2, use 1 and 3.
Fill all three blanks to create a map named lengths where keys are words in words slice and values are their lengths, but only for words longer than 3 characters.
lengths := map[string]int{}
for _, word := range words {
if len(word) [3] 3 {
lengths[[1]] = [2]
}
}The map keys are words, so word is the key. The values are lengths, so len(word) is the value. The condition checks if the word length is greater than 3, so use >.