Logo

Programming-Idioms

Insert value v for key k in map m.
Implementation
Python

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another Python implementation.

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
m[k] = v
$m[$k] = $v;
m[k] = v
m[k] = v;
uses fgl;
m.KeyData[k] := v;
use std::collection::HashMap;
m.insert(k, v);
$m{$k} = $v;
m.set(k, v);
m[k] = v;
m[k] = v;
m[k] = v;
m[k] = v;
import qualified Data.Map as Map
newM = Map.insert k v m
(assoc m k v)
m.k = v
m[k] = v
m.put(k, v);
m at: k put: v.