Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: count characters

Given a string count how many time each character appears

package main

import "fmt"

func main() {
	text := "This is a very long text. OK, maybe it is not that long after all."
	fmt.Println(text)

}

Expected output:

This is a very long text. OK, maybe it is not that long after all.
r: 2
n: 3
m: 1
T: 1
s: 3
y: 2
g: 2
t: 7
.: 2
,: 1
f: 1
h: 2
v: 1
i: 4
e: 4
l: 4
o: 3
x: 1
O: 1
K: 1
b: 1
a: 5