diff --git a/separar_letras/main.go b/separar_letras/main.go index 70ab57f..100ccf2 100644 --- a/separar_letras/main.go +++ b/separar_letras/main.go @@ -7,5 +7,19 @@ func main() { fmt.Scan(&palabra) // TODO: fix this garbage - fmt.Printf("Your word is %v\n", palabra) + //fmt.Printf("Your word is %v\n", palabra) + //var count = len(palabra) + //fmt.Printf("Length is %v\n", count) + + // So I'm converting the string to an array of "runes", which are apparently the equivalent of characters + var letras = []rune(palabra) + + // Here I'm just using len function to properly count it because if you try to len a plain string it's just gonna + // return the bytes, not the actual amount of characters, so UTF-8 is not gonna be happy + fmt.Printf("%d letters\n", len(letras)) + + // I really have to start learning when to use printf and when to use println, println is useful + for i := 0; i < len(letras); i++ { + fmt.Println(string(letras[i])) + } }