How to use key value loop in Go

1 Answer

0 votes
package main

import "fmt"

func main() {

	arr := map[string]string {"a": "go",
							  "b": "c++",
							  "c": "php",
							  "d": "python",
	}
	// for {key}, {value} := range {list}
	for key, value := range arr {
		fmt.Println(key, " - ", value)
	}
}
 
 
 
/*
run:
 
a  -  go
b  -  c++
c  -  php
d  -  python
 
*/

 



answered Aug 7, 2020 by avibootz

Related questions

3 answers 429 views
1 answer 145 views
145 views asked Dec 10, 2022 by avibootz
1 answer 241 views
241 views asked Nov 4, 2020 by avibootz
1 answer 110 views
1 answer 142 views
...