Iterate over two strings at the same time
go
Solution
Not sure IIUC, but for example:
package main
import (
"fmt"
)
var (
ascii = []rune("string1")
shifted = []rune("STRING!")
)
func main() {
for i, v := range ascii {
fmt.Printf("%c%c\n", v, shifted[i])
}
}
Also here: http://play.golang.org/p/2ruvLFg_qe
Output:
sS
tT
rR
iI
nN
gG
1!
Problem
I am just wondering if there is any beautiful way to iterate over two strings at the same time: ``` var ascii_runes = []rune(string_1) var shifted_runes = []rune(string_2) for i := 0; i < len(string_1); i++ { fmt.Println(string(ascii_runes[i]) + string(shifted_runes[i])) } ```