Redact sensitive nested values

Write codeMedium25 minPalantir style

Your task

Redact sensitive values from a nested structure before logging. Given a JSON-like structure (dicts, lists, and scalars) and a list of sensitive key names (case-insensitive), return a deep copy where any dict value whose key matches a sensitive name (compared lowercased) is replaced with the string '[REDACTED]', recursing into nested dicts and lists. Non-matching scalars are left as-is. Do not mutate the input.

Examples

redact(data: any, sensitive: list[str]) -> any
Example 1
Inputredact({"user": "alice", "password": "p@ss"}, ["password"])
Output{"user": "alice", "password": "[REDACTED]"}