import string


def whitelisted(
    s, whitelist="_-" + string.ascii_letters + string.digits, substitute="_"
):
    """
    >>> whitelisted("ab/cd#ef(gh")
    'ab_cd_ef_gh'

    >>> whitelisted("ab/cd#ef(gh", substitute='')
    'abcdefgh'
   """
    return "".join(c if c in whitelist else substitute for c in s)