<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hash_values(values, alg="md5"):
 """Hash a list of values."""

    import hashlib
    if alg not in ['md5', 'sha1', 'sha256']:
        raise Exception("Invalid hashing algorithm!")

    hasher = getattr(hashlib, alg)
    if type(values) == str:
        output = hasher(values).hexdigest()
    elif type(values) == list:
        output = list()
        for item in values:
            output.append(hasher(item).hexdigest())
    return output