Start learning free

LESSON 67 OF 671 · STRINGS I

Uppercase and Lowercase in Go

Lesson

In Go, you can convert a string to uppercase or lowercase using strings.ToUpper() and strings.ToLower():

s := "Hello World"

upper := strings.ToUpper(s)
// upper == "HELLO WORLD"

lower := strings.ToLower(s)
// lower == "hello world"

strings.ToUpper converts all characters to uppercase, and strings.ToLower converts all characters to lowercase.


Assignment
Follow the Coding Tutorial and create upper and lower versions of word!


Hint
Use strings.ToUpper(word) for uppercase and strings.ToLower(word) for lowercase.

STEP 1 OF 2
    Ctrl + Enter to check