9951 explained code solutions for 126 technologies


golangHow to use range


package main

func main() {
  list := [7]int{3,4,5,2,2,4,5}

  for k, v := range list {
    print(k, ":", v, ";")
  }
}ctrl + c
package main

default package declaration

func main() {

declare main function that will be launched automatically

for k, v := range list

iterate over list array with range and having all values in v variable and key in k variable