Seems as if len(s) (with s being a string) returns the same result as len([]byte(s)), but len([]rune(s)) returns a potentially smaller nummer, but never a bigger one.
const N = 10
parole := make([]string, N)
for i := 0; i < N; i++ {
fmt.Scan(&parole[i])
}
fmt.Println(piuCorta(parole))
}
func piuCorta(parole []string) int {
count := 0
for _, len := range parole {
for _, letter := range len {
if len < letter {
parole = len
fmt.Printf("%#v has a lenght of %v bytes", count, len([]byte(s)))
}
}
}
return parole
}
I’ve followed your istructions but idk why it gives me errors
Ask yourself what are the types of len and letter and what you expect to be the result of the operation above. BTW, it is poor practice to reuse the names of builtin functions for variables.