Removing all letters except for the last one

Report a typo

Suppose you have a Go program that takes as an input a random word of the string type.

Your task is to use slice expressions along with the built-in len() function to remove all the letters from the word, except for the last one.

For example, if the input word is uncopyrightable, your program should only print e.

Sample Input 1:

uncopyrightable

Sample Output 1:

e
Write a program in Go
package main

import "fmt"

func main() {
// DO NOT delete or modify the code block below, it reads a random input word
var word string
fmt.Scan(&word)

// Use slice expressions with the len() function
// to remove all the letters from 'word' except for the last letter.
word = word[len(?)?]

fmt.Println(word)
}
___

Create a free account to access the full topic