Dict (Map)
The map, exactly, is Python's dictionary.
Golang version
package main
import "fmt"
func iterate_map_A(A map[string]string) {
for key, value := range A {
fmt.Println(key, value)
}
}
func iterate_map_B(A map[string]int) {
for key, value := range A {
fmt.Println(key, value)
}
}
func main() {
mapA := make(map[string]string) // make a map where the key is string, the value is also a string
mapA["anyone"] = "lacks of patience"
mapA["that's"] = "bad"
iterate_map_A(mapA)
fmt.Println("")
mapB := map[string]int{"me": 100, "you": 0}
iterate_map_B(mapB)
}Python version
What if we want a type of dict-list combination?
dict-list combination?Last updated
Was this helpful?