Iterate List

Examples Filter
package main

import "fmt"

func main() {

    nums := []int{2, 3, 4}
    sum := 0
    for _, num := range nums {
        sum += num
    }
    fmt.Println("sum:", sum)

    for i, num := range nums {
        if num == 3 {
            fmt.Println("index:", i)
        }
    }

    for i, c := range "go" {
        fmt.Println(i, c)
    }
}
Last Run  :
sum: 9
index: 1
0 103
1 111