Allowlist input sanitization
Your task
Implement allowlist-based input sanitization. Given a value string and an allowlist (a list of permitted characters), return a new string containing only the characters of value that appear in the allowlist, preserving their original order. Characters not on the allowlist are dropped entirely. This is the safe alternative to denylisting dangerous characters.
Examples
sanitize_input(value: str, allowlist: list[str]) -> strExample 1
Input
sanitize_input("ab<script>12", ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"])Output
"abscript12"