Slicing extracts part of a string.
In Go, a slice uses the form message[start:end]. The start index is included, and the end index is excluded.
message := "Coding feels great"
firstWord := message[0:6] // "Coding"
middleWord := message[7:12] // "feels"
lastWord := message[13:] // "great"
If the slice goes to the end of the string, you can omit the end index, like message[13:].
Assignment
Follow the Coding Tutorial and create the three word variables from message.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
