is fine if value is immutable e.g., a string, number.
Your code doesn't solve the mutability problem (each value is the exact same object. If you modify it for one key; the values are modified for all keys).
For a mutable type you need to create a new value for each key:
I know that, but I willfully replicated the original code behavior and made it idiomatic (which has the advantage of making it both obvious and easily adjustable)
Your code doesn't solve the mutability problem (each value is the exact same object. If you modify it for one key; the values are modified for all keys).
For a mutable type you need to create a new value for each key: