Read-Only Array

mediumnumpy_basics

Implement make_immutable(a).

Return the array a made read-only: its values stay the same, but any attempt to assign into the result (e.g. result[0] = 1) must raise. (NumPy arrays expose a flags.writeable flag for exactly this.)

Your solution

Edit make_immutable and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

Every array has a.flags.writeable — set it to False to freeze the array.