How can I print every second character in a string? Example:
Hello, my name is Jack! There must be something like this (maybe a mistake): el,maeiak
I wondered if the string was iterable in Go and I wrote the following code:
package main import "fmt" func main() { src := "Hello, my name is Jack!" for i, ch := range src { if i % 2 == 0 { fmt.Printf("%c", ch) } } } I got the following conclusion:
Hlo ynm sJc! Source: https://ru.stackoverflow.com/questions/919750/
All Articles