How do I invert a map of string to int?

Go, Map Inversion, Map of String to Int
This example demonstrates how to invert a map in Go where the keys are strings and the values are integers.
package main import ( "fmt" ) func main() { // Original map of string to int originalMap := map[string]int{ "one": 1, "two": 2, "three": 3, } // Inverted map of int to string invertedMap := make(map[int]string) for key, value := range originalMap { invertedMap[value] = key } fmt.Println("Original Map:", originalMap) fmt.Println("Inverted Map:", invertedMap) }

Go Map Inversion Map of String to Int