String indexes must stay inside the valid range.
For a string with length len(message), the first index is 0 and the last valid index is len(message) - 1.
message := "I love pancakes"
fmt.Println(string(message[len(message)-1])) // last character
Trying to access message[len(message)] goes past the end: the program panics with index out of range [15] with length 15.
Assignment
Follow the Coding Tutorial and print the last character without exceeding the string bounds.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
